Davis (1-5) struck out Mike Moustakas to start the inning before allowing a pair of one-out walks. After Jonathan Schoop popped out, Thames hit a 1-1 pitch deep into the right-field bleachers to end it.
Miller Park continues to be a house of horrors for Davis, who also allowed a walk-off homer to Travis Shaw in his last appearance at Milwaukee with the Cubs on Sept. 23, 2017.
Corbin Burnes (2-0) came in with a runner on first in the ninth and retired the side for the win.
Christian Yelich homered for Milwaukee, while Trevor Story and Carlos Gonzalez went deep for the Rockies.
Thames' late heroics turned around what had been a pitchers' duel in which the Rockies' German Marquez got the better of Junior Guerra.
Marquez allowed two runs on three hits and two walks in seven innings. He struck out nine and retired 15 in a row at one point.
Guerra went eight innings, allowing three runs on five hits and two walks while striking out six.
Guerra had been sent home earlier in Milwaukee's seven-game road trip to get a good night's rest because of a late start in the series finale in Los Angeles. The rest of the Brewers straggled home at 6 a.m. local time Friday following a 21-5 loss to the Dodgers that set a franchise record for runs allowed.