Ramirez hit his milestone home run in the fourth, a two-run double in the fifth for a 5-0 lead and an RBI single in the seventh for a 6-5 lead, but it took pinch-hitter Caleb Gindl's go-ahead sacrifice fly against right-hander Bryan Morris in the eighth to finally take the lead for good. The Brewers won for the 11th time in their last 17 road games, and denied the Pirates an opportunity to keep pace in the NL Central.
"That seemed like a playoff game for us," Ramirez said. "It's nice to be in the race -- or playing the teams that are in the race. We'll play St. Louis again, Cincinnati again. We have to [look at it like that]. Right now, that's our playoffs. We aren't going to the playoffs, but we have something to play for, and that's playing spoilers."
The Brewers spoiled the night for 23,801 Pirates fans despite a career-high 13 hits allowed by Milwaukee starter Kyle Lohse, and a critical misplay by right fielder Norichika Aoki that aided Pittsburgh's comeback from a five-run deficit.
"We made it a lot tougher than we needed to," said Brewers manager Ron Roenicke. "One play got us, but other than that we played a great game. … [the Pirates] aren't going to quit. Certainly, when we were [ahead] 5-0, I felt OK.
"That didn't last long."
After the Brewers scored three runs off struggling Pirates starter Jeff Locke in the fifth, the Pirates answered right back against Lohse, scoring four in the bottom of the inning after Aoki, nearing the right-center-field wall with center fielder Carlos Gomez closing fast, let a Felix Pie fly ball tick off the end of his glove for what was ruled an RBI double. Jose Tabata followed with an infield single and then Neil Walker hit a misplaced cutter for a booming, three-run home run that sailed over Aoki's head.
Suddenly, the Brewers' lead was cut to 5-4.
"We were quiet there for most of the first half [of the game], so it was nice to put up a four-spot," Walker said. "It was a strange back-and-forth game."
Aoki said he temporarily lost the ball in the lights.
"At the last moment, the light just caught my eye," Aoki said through a translator. "I could have caught it. I should have."
He added: "I feel bad for what I did to Kyle. These guys, they can gain momentum at any time, and they actually did at that moment. These mistakes bug me more than not getting a hit."
Roenicke suggested that Lohse lost focus after that play and considered removing the veteran from the game. But, Roenicke said, "He told me he was OK. I needed to see he was OK, that he wasn't mentally out of the game. He assured me that he wasn't."
But Lohse lasted only four batters into the sixth. He found more trouble after Pirates right fielder Andrew Lambo hit a single that took a giant bounce over Brewers first baseman Yuniesky Betancourt. Lambo advanced when Jordy Mercer poked a single through the hole on the right side, and he scored the tying run when Pie's sharp single snuck under Betancourt's glove.
"I'm making my pitches, they're finding holes, and you can't do much about it," said Lohse, who was lasted 5 1/3 innings and was charged with five runs -- all earned because of the ruling on Pie's ball in the lights. "You have to make more pitches."
The Brewers briefly reclaimed the lead on Ramirez's RBI single in the seventh, but Pedro Alvarez erased it in the bottom of the frame when he lined a home run off the right-field foul pole -- his 32nd of the year. It came off Brewers reliever Rob Wooten, who hadn't allowed a homer in his first 13 Major League appearances.
But Wooten wound up with his third win of the season when Betancourt scored from third on Gindl's sacrifice fly in the eighth.
Brandon Kintzler held the lead in a perfect eighth, and Jim Henderson converted his 22nd save in the ninth. Henderson has saves in each of his last 12 appearances, a Brewers record.
"Mentally, I'm exhausted after that," said catcher Jonathan Lucroy, who went 3-for-4 with an RBI single and two runs. "That other team's battling, we're battling, and I'm exhausted."
Ramirez singled again in the ninth for a season-high four hits. His milestone homer came when Locke elevated a change-up and Ramirez hit it to left-center field, the deepest part of PNC Park, into the home bullpen. Pirates bullpen coach Euclides Rojas retrieved the baseball for Ramirez.
The Pirates were still playing down the road at Three Rivers Stadium on June 12, 1998, when Ramirez sent a Karl pitch down the left-field line for the first home run of a career that would span parts of three decades.
Ramirez is 14th among active players with 350 home runs, and one of only 90 players in Major League history to hit that many. He has hit 175 of his homers in home games, and 175 on the road. Ramirez's 347 home runs as a third baseman ranks seventh all-time.
He had to be reminded late Tuesday that No. 1 came at the Brewers' expense.
"It's been a while, 1998. I was a teenager, 19 years old," Ramirez said. "Not any more. I'm an old man, now."