PITTSBURGH -- On a day in which the Pirates, already significantly wanting in the power department, bid adieu to the club's home run leader, they were carried by none other than the long ball. Go figure.

With Adam LaRoche still in uniform and watching his final game as a Pirate from the PNC Park dugout, his former teammates clubbed a season-high five home runs, including Brandon Moss' walk-off shot in the ninth, to propel Pittsburgh to an 8-7 win over nemesis Milwaukee in front of 21,186 on Wednesday.

"That was a fun game to play in and watch," said Garrett Jones, who contributed a solo homer in the win. "I was confident we were going to win the game and felt like it as just a matter of time before somebody stepped up."

With four homers in the first three innings, this game looked to be on its way to being decided much earlier than in the final at-bat, though that's what it came to. It wouldn't be until Moss, hitless on the afternoon before driving a 3-1 pitch from Brewers reliever Mitch Stetter over the center-field wall, that the Pirates could finally celebrate a series win over the Brewers.

The walk-off shot was a first for Moss, who hadn't done so at any previous level.

"There's nothing like that," he said of rounding third and seeing his teammates celebrating at home. "Even though you know you're about to get the [stuffing] beat out of you, it's still fun."

And waiting in the group was LaRoche, who had opted to stay and watch the rest of the game after being informed by general manager Neal Huntington in the sixth that he had been traded to Boston.

"That was pretty neat to be able to go out there and share in that," LaRoche said. "Just get to visit with them a little bit more and watch [brother] Andy be in the same uniform one more time."

The fact that the Pirates entered the bottom of the ninth tied was credit to what Matt Capps did in the top of the inning. After Brewers outfielder Mike Cameron tripled with one out, All-Star Ryan Braun, who had already driven in four on a homer and a three-run double, came to the plate looking to give Milwaukee its first lead since the fifth.

But relying heavily on his slider, Capps got Braun to go down swinging. After Capps intentionally walked Prince Fielder, Casey McGehee swung through an 0-2 high fastball. Cameron was left on third.

Capps was told to prepare to return to the mound in the 10th, but moments later, he walked off with his second win of the season.

This game would be defined by the home runs hit, especially considering the dearth of homers this club has produced. Though they had nine in this six-game homestand, the Pirates came into Wednesday ranked 28th in the Majors with 72 this year.

Yet, 13 hitters into this game, the Pirates already had four.

"There's no rhyme or reason," catcher Ryan Doumit said when asked about the contagious nature of the long ball. "We're swinging the bats well. To perform like that against the Brewers gives us a lot of confidence."

It was Doumit who would have two of his club's five homers, beginning with a two-run blast in the first. His second homer of the afternoon, a third-inning solo shot, came with the benefit of instant replay. The hit was initially ruled a double, but the call was reversed after crew chief Wally Bell used instant replay to determine that the ball struck a fan above the yellow line.

That marked the second time that instant replay has been used at PNC Park this season, and in both circumstances, the call has been overturned.

Doumit, who spent much of the past three months on the disabled list, hadn't homered since April 13.

"His timing is starting to get better," Pirates manager Russell said. "He's got a better approach and is seeing the ball better. He's laying off pitches that are enticing to hit but ones that he doesn't like to hit. He's coming along real well."

Doumit's second homer came three pitches after Jones went deep with his ninth homer in his first 17 games with the Pirates. It was a solo shot, as have been all nine of his long balls, something that has begun to eat at the rookie a bit.

"Hopefully I'll get on a roll and start getting some hits with guys on base," he said. "It's kind of starting to frustrate me a little bit. Right now, I'd take two homers and 30 RBIs."

And two batters before Jones, Andrew McCutchen had homered to lead off the inning. That three-homer third gave the Pirates their first three-homer inning in almost exactly a year.

"Some of our power started to show, and hopefully it continues," Russell said. "We need, as a team, to continue to swing the bat. We all know that's been our Achilles' heel this year. Hopefully we come out of that the second half."

That early barrage of homers gave the Pirates a 5-2 lead, but it was a lead that starter Paul Maholm couldn't keep. He was knocked out of the game with two outs in the fifth after the Brewers took the lead with a five-run inning. He allowed seven runs for the fourth time this season.

The Pirates did, however, immediately erase that two-run deficit with two-out RBI doubles by Andy LaRoche and Ramon Vazquez in the bottom half of the inning. And then the bullpen -- led by Joel Hanrahan's 2 1/3 shutout innings -- stepped up to pave the way for Moss.

"I think we have started to play together as a team pretty well," Moss said. "We have a lot of young players, and the more at-bats that we get, the more experience we get, the better we'll be and the more consistent we'll be."