PITTSBURGH (AP) -- Yovani Gallardo has spent much of his career toying with the Pittsburgh Pirates.
On Wednesday night, the Pirates finally found a way to flip the script on their nemesis.
Neil Walker laced a two-run single off the Milwaukee right-hander in the sixth inning, Wandy Rodriguez pitched seven strong innings and the Pirates beat the Brewers 3-1 on Wednesday.
Gallardo (3-3) came in 7-0 in his last eight starts against the Pirates but was outdueled by Rodriguez and outsmarted by Walker, who guessed right when he stepped to the plate with the bases loaded and one out.
''He has to come to you,'' Walker said. ''He has to throw strikes and if you stay in your own approach and don't go chasing pitchers pitches and more often than not you're going to at least hit a barrel.''
When the switch-hitting Walker, batting left-handed, saw the cutter he was expecting, he slapped it up the middle for his first RBIs in nearly a month. The second baseman came off the 15-day disabled list with a hand injury on Monday then gave the Pirates the jolt they needed to post consecutive victories over the Brewers for the first time in nearly four years.
''These are important moving forward for confidence,'' Walker said. ''But being at home here, we feel like it doesn't matter who we play, we need to take advantage of that home field advantage.''
The Pirates moved six games above .500 for the first time this season with the victory. Rodriguez (4-2), who was knocked around by the Brewers when he faced them last month, responded by expertly working himself out of trouble spots the first four innings before eventually giving away to Pittsburgh's red-hot bullpen.
Rodriguez (4-2) gave up six hits, walking one and striking out five then watched Jason Grilli worked the ninth for his National League-leading 16th save.
''It was the start we needed, a little bit better than their guy,'' Pittsburgh manager Clint Hurdle said. ''Their guy was good too.''
Gallardo almost always is when he faces Pittsburgh. He entered the game with a 10-2 lifetime record against the Pirates and was solid enough to make it 11-2 after surrendering three hits over six innings, walking four and striking out four. He just received little help offensively.
Rickie Weeks hit his third homer to provide Milwaukee's only run. Norichika Aoki had two hits for the Brewers but couldn't stop Milwaukee from falling to 2-10 in its last 12 games.
''Guys are giving it all they have,'' Gallardo said. ''It's not like we're trying hard. It's just the way the game is, sometimes. You've just got to keep grinding it out.''
Milwaukee has dominated the Pirates over the last six years, winning 73 percent of the meetings between the two clubs and knocked Rodriguez around during his last start against the Brewers two weeks ago.
The left-hander was rocked for seven runs in 4 2-3 innings of an eventual 10-4 loss on April 29.
Things were decidedly smoother this time around.
Working both sides of the plate, Rodriguez kept the Brewers off balance and buckled down when pressed. Milwaukee put runners in scoring position in each of the first four innings but had nothing to show for it.
No missed opportunity loomed larger than the one the Brewers created in the fourth when Jonathan Lucroy led off with a triple to right. Rodriguez induced Carlos Gomez and Weeks to hit harmless infield flies before Alex Gonzalez rolled a routine grounder to shortstop to end the threat.
''He picked it up and laid it down for us and he battled from start to finish,'' Hurdle said.
Gallardo was just as sharp. Pittsburgh managed just one hit through the first six innings before Starling Marte doubled to center leading off the sixth. Andrew McCutchen and Gaby Sanchez worked one out walks to load the bases to set up Walker's tiebreaking single.
The hit ended an 0-for-23 skid with runners in scoring position by the Pirates and was just enough to deal Gallardo a rare loss to Pittsburgh
''The pitch was off the plate and below the knees,'' Gallardo said. ''Sometimes, you've got to tip your cap to the hitter. I threw it where I wanted to throw.''
Weeks drew the Brewers within a run in the seventh with a homer to the bleachers in left field off Rodriguez but baseball's best one-two punch out of the bullpen shut the door.
Set-up man Mark Melancon retired the Brewers in order in the eighth and Grilli did the same in the ninth as Pittsburgh remained undefeated (17-0) when leading after seven innings.
The Pirates gave Grilli a little extra cushion in the eighth when McCutchen scored from third after Weeks threw wide of first after making a diving stop on a grounder by Walker.
NOTES: Pittsburgh recalled INF Jordy Mercer on Wednesday after placing John McDonald on the 15-day disabled list with a bad back. Mercer started at shortstop and went 1 for 2 ... The Brewers plan to call up veteran reliever Francisco Rodriguez on Thursday. The 31-year-old Rodriguez signed a minor-league deal with the Brewers in April. The four-time All-Star went 2-7 with a 4.38 ERA in 78 games with Milwaukee in 2012 ... ... Umpire Fieldin Culbreth worked at third base on Wednesday night. He left Tuesday night's game after being struck in the neck with a ball ... The series concludes on Thursday. Hiram Burgos (1-1, 6.86 ERA) starts for the Brewers against Pittsburgh's Francisco Liriano (1-0, 1.69).