SAN FRANCISCO -- Yovani Gallardo and Carlos Villanueva shared a bear hug in the tunnel between the dugout and the clubhouse Wednesday night after pitching both ends of the Brewers' first win of the season.

The best of friends started -- Gallardo worked 6 2/3 solid innings and became the first pitcher ever to homer off Randy Johnson -- and finished -- Villanueva pitched a perfect ninth for his third career save -- the Brewers' 4-2 win over the Giants at AT&T Park, sealing manager Ken Macha's first Milwaukee win.

"I told him every time I get a save for [Gallardo] he has to give me $1 million," said Villanueva, filling in as the Brewers' closer while Trevor Hoffman is on the disabled list. "He said whenever the team gives him $10 million for every win, he'll give it to me.

"We joke about it, but when it's time for baseball, him being a very close friend of mine, it's special. I get to clean up his mess."

Thanks mostly to Gallardo's two-out, two-strike, three-run home run off Johnson in the fifth inning, which snapped a 1-1 tie, there was not much mess to clean up Wednesday outside of the seventh inning. Todd Coffey inherited a bases-loaded jam from Gallardo and lefty reliever Mitch Stetter with one run already across in the frame.

Coffey retired Giants cleanup hitter Bengie Molina on an inning-ending groundout, then worked a 1-2-3 eighth inning and watched Villanueva do the same in the ninth. The Brewers and Giants will play the rubber match of their three-game series Thursday afternoon.

"That was cool," said Macha, who was presented with the game ball after his first managerial win since the A's clinched a spot in the 2006 American League Championship Series. "I never got a ball in Oakland. They wanted it back."

Gallardo had to settle himself after a bit of a shaky start. He walked Randy Winn leading off the game and Winn moved to third on a stolen base and an error charged to Brewers catcher Jason Kendall. Gallardo hit Fred Lewis with a pitch but escaped early damage when Molina grounded into an inning-ending double play.

"That was huge," Macha said.

Gallardo went on to allow two runs on six hits with two walks and six strikeouts for his first win since Sept. 17, 2007. He missed most of 2008 because of knee injuries.

"There's always a little bit of excitement, anxiousness, adrenaline," Gallardo said. "I was able to make a pitch there and get a ground-ball double play."

But the game will be remembered less for his first-inning escape and more for his homer off Johnson, five wins shy of the magical 300 mark and making his Giants debut. Johnson retired the first five hitters he faced before Mike Cameron belted a home run in the second inning for a 1-0 Brewers lead. Cameron entered the game 2-for-29 in his career against Johnson with 18 strikeouts.

San Francisco tied the game at 1 in the bottom of the second, when Travis Ishikawa singled, moved to third on Aaron Rowand's ground-rule double and scored on Emmanuel Burriss' groundout. The game remained tied until the top of the fifth, when Johnson retired the first two hitters he faced but then surrendered a double down the left-field line to Bill Hall.

Johnson intentionally walked No. 8 hitter Jason Kendall to face Gallardo, who turned on a 1-and-2 pitch way up in the zone and launched it over the left-field wall for a 4-1 Brewers lead.

"You tip your hat to him," Johnson said. "He pitched a good ballgame and got the big hit."

Gallardo had retired to the clubhouse for his post-start battery of ice and exercises by the time Villanueva took the mound in the ninth. The 25-year-old Dominican entered the year with two big league saves, but both were of the "three quality innings" variety in Brewers blowout wins.

"This," he said, "was the first real one."

He made it look pretty easy, retiring Burriss on a foul popout and then striking out pinch-hitter Andres Torres and Winn to end the game. The Brewers are counting on Villanueva to fill in for Hoffman, who remains sidelined by a rib-cage muscle strain.

"I was more nervous sitting in the dugout," Villanueva said. "I hated that, just anticipating it. Once I got out on the mound, getting trashed by the fans, it felt way better. The nervousness went away after I got on the mound.

"I told myself, 'This is the seventh inning, like I've done a lot of times. Just get three outs.' I try to leave the game the same way I got it, so that means throw zeros. I have to see it as just another inning. Obviously, it's [magnified] in the ninth inning. I refuse to let myself get carried into all that."

Said Gallardo: "He's going to do a good job for this team."