PITTSBURGH -- Aramis Ramirez's first home run came so long ago he can barely remember it.
"I know I was just a kid, a 19-year-old kid," the Milwaukee Brewers third baseman said.
Ramirez had three hits, including his 350th career home run, and drove in four runs to lead the Milwaukee Brewers over the Pittsburgh Pirates 7-6 on Tuesday night.
Coincidentally, No. 350 came just a short walk from where he hit his first -- which also came against his current team. Playing for the Pirates on June 12, 1998, Ramirez took Milwaukee's Scott Karl deep at Three Rivers Stadium.
The 16-year veteran third baseman helped stake the Brewers to a 5-0 lead in the fifth inning, but the Pirates rallied to tie it in the sixth. But Milwaukee pulled out the win when rookie pinch-hitter Caleb Gindl hit a tiebreaking sacrifice fly in the eighth inning.
"If you would have told me back when I was 19 that I'd hit at least 350 home runs in my career, I would have taken that," Ramirez said. "I was a kid then and I'm an old man now but it just goes to show you that if you play long enough you can put up some numbers."
The Brewers won their third in four games while handing the Pirates their third straight loss. Pittsburgh dropped 1 1/2 games behind St. Louis in the NL Central after the Cardinals beat Cincinnati 6-1.
Milwaukee's Norichka Aoki reached base in all five plate appearances, with two singles and three walks. Jonathan Lucroy added three hits, and Gennett had two.
"I like what we're doing offensively," Brewers manager Ron Roenicke said. "That was an outstanding offensive performance."
Pedro Alvarez went 4-for-4 with a walk, and hit his NL-leading 32nd home run for the Pirates. Neil Walker had a three-run homer among his two hits. Andrew McCutchen, Andrew Lambo and Felix Pie also had two hits.
Earlier Tuesday, the Pirates acquired right fielder Marlon Byrd and catcher John Buck from the New York Mets to bolster an offense that ranks 24th in the major leagues in runs. Both players are expected to join the team on Wednesday.
With the Pirates down by a run, McCutchen doubled and Alvarez walked with one out in the ninth, but Jim Henderson held on for his 22nd save in 25 opportunities.
Rob Wooten (3-0) allowed Alvarez's homer but pitched 1 1/3 innings for the win.
"It was as strange game. Real strange," Walker said. "Back and forth, back and forth. But it was no different than what we've played all year. Down 5-0, a lot of teams pack it in. But we have a lot of heart and nobody's throwing in the towel until the last out."
Both starting pitchers had rough outings. The Brewers' Kyle Lohse gave up five runs and 13 hits in 5 1/3 innings. Pirates All-Star left-hander Jeff Locke was tagged for five runs and eight hits in 4 2/3 innings.
Lohse had been 4-1 with a 2.05 ERA in seven starts since the All-Star break.
Locke has struggled of late, allowing 16 runs and 23 hits in 11 1/3 innings in his last three starts. Over his last seven outings, he is 0-2 with a 7.02 ERA.
Alvarez tied it 6-6 by lining a solo home run off the right-field foul pole, snapping a tie with Arizona's Paul Goldschmidt for the league lead.
"Alvarez is hot and he just smoked that ball," Roenicke said.
Milwaukee had gone ahead by a run in top of the inning when Ramirez lined a two-out RBI double to center that scored Lucroy, who had singled.
A first-inning run scored when Ramirez grounded into a double play. He hit a solo home run, his eighth of the season, with one out in the fourth. After Lucroy hit a two-out RBI single in the fourth, Ramirez followed with a two-run double that put the Brewers up 5-0.
The Pirates came back to tie it with four runs in the fifth and one in the sixth.
Pie drove in the first run with a pinch-hit double that bounced off Aoki's glove in right field and, one batter later, Walker hit his ninth home run, a three-run shot that carried over the right-field stands.
Lohse grabbed his head and shouted an obscenity when Aoki failed to make the play.
"You can't afford to give a team like the Pirates second chances and they'll take advantage, which they did because I didn't make pitches after that," Lohse said. "I let the inning get away from me there but fortunately we were able to still win."
Pie, who remained in the game to play left field, made it 5-5 in the sixth with a run-scoring single but the Pirates were never able to gain a lead.
"It's a good win for us," Ramirez said. "We're in fourth place (in the NL Central) and we're not going to playoffs but it's fun to play teams that are going to the playoffs. These felt like a playoff game."
Pittsburgh LF Starling Marte was examined by hand specialist Thomas Graham on Tuesday and no structural damage was found in his bruised right hand. Marte, on the disabled list since Aug. 19, was told he can't swing a bat for at least two more weeks. . Milwaukee rookie LF Khris Davis' 11-game hitting streak ended as he went 0-for-5. . Pirates 1B Garrett Jones did not start but his slump extended to 1-for-34 when he flied out with the bases loaded in the sixth inning as a pinch-hitter. . LHP Tom Gorzelanny (3-5, 3.60) will start for Milwaukee on Wednesday night against RHP Charlie Morton (5-3, 3.42).