William Contreras had three hits and three RBIs and Willy Adames and Brice Turang contributed three hits each for Milwaukee, which had lost three in a row.
Brewers starter Brandon Woodruff allowed four runs and three hits in 5 1/3 innings, striking out four and walking two.
Rangers starter Andrew Heaney had his second straight short outing, lasting just 3 2/3 innings before he was pulled.
Heaney, who was lifted after 1 1/3 innings in his previous start on Aug. 12 against the San Francisco Giants, allowed three runs and seven hits with three strikeouts and a walk. He threw 84 pitches.
Nathaniel Lowe and Mitch Garver homered for Texas, which has lost two in a row after winning 12 of 14.
After the Brewers could not take advantage of leadoff singles in the first and second innings, Milwaukee's Christian Yelich doubled to the opposite field in left to lead off the third. Contreras followed with a double to center to drive in Yelich for a 1-0 lead.
After a groundout moved Contreras to third, Mark Canha laced an RBI double. Adames followed with an RBI single to stretch the lead to 3-0.
Woodruff did not allow a hit through the first three innings, but after issuing a leadoff walk to Corey Seager in the fourth, he served up a two-run homer to Lowe.
One out later, Garver slammed a solo home run to tie it 3-3.
Seager doubled to lead off the sixth and Elvis Peguero (3-4) replaced Woodruff with one out and surrendered an RBI single to Adolis Garcia to give the Rangers a 4-3 lead.
The first two Brewers reached base off Josh Sborz (5-5) in the seventh before Santana clubbed a three-run homer to right field to move Milwaukee back ahead 6-4.
The Brewers loaded the bases with one out in the eighth, and Contreras came through with a two-run single to extend the edge to 8-4.
A fielder's choice groundout from Canha brought home another run to make it 9-4.
Texas scored four runs in the ninth on J.P. Martinez's RBI groundout, back-to-back RBI doubles by Ezequiel Duran and Travis Jankowski and a run-scoring grounder from to Marcus Semien to make it 9-8. Devin Williams finally got Seager to fly out to center, sealing his 29th save.
—Field Level Media