The Brewers won their fourth in a row and handed the faltering Pirates their fourth straight loss.
Pittsburgh battled back from an early two-run deficit to tie the contest in the fourth and it remained a 2-2 game until Milwaukee put together its decisive inning.
Milwaukee loaded the bases with two outs in the seventh, thanks in part to reliever Jared Hughes hitting a batter and walking another. Ramirez then cleared the bases with his double to center and he scored on a single by Corey Hart.
Michael Fiers (7-6) equaled a career best with 10 strikeouts over 6 2/3 innings and allowed three runs on five hits to get the win.
The loss went to Wandy Rodriguez (8-13), who was touched for three runs on six hits in 6 2/3. Rodriguez has lost seven of his last eight starts.
Kate Middleton recycles dress at movie premiere
Couple mistakenly served bag of cash at McDonald's drive-thru