Ransom's blast capped an outburst of eight runs over the seventh and eighth innings that gave Milwaukee a seemingly comfortable 8-4 lead, but it turned out to be the game-winner as the Astros staged a late rally.
Nyjer Morgan added a two-run shot and Cesar Izturis went 3-for-4 with a run-scoring single for the Brewers, who won the opener of a three-game series.
Reliever Livan Hernandez (3-1) earned the victory despite coughing up three runs -- including one in the eighth that allowed Houston to forge a 4-4 tie, and two more in the ninth.
Steve Pearce went 2-for-3 with three RBI, including one each in the eighth and ninth innings as the Astros tried to battle back.
Francisco Cordero (0-3) took the loss for Houston, which fell for the 13th time in 14 games.
Interpol investigating stolen passports on missing flight
Susan Sarandon 'very excited' about daughter's pregnancy