The Pirates couldn’t quite get to Milwaukee starter Yovani Gallardo Thursday night, but they managed to outlast him.

Gallardo recovered from a two-run first inning to work without much trouble through the Pirates lineup for the next five. He and Edinson Volquez, having dueled to a draw, gave way to their respective bullpens, and the Pirates took advantage.

Nine runs against the Brewers bullpen gave the Pirates an 11-2 victory Thursday night against Milwaukee at PNC Park.

The Pirates hit four home runs, three of them against Brewers relievers. Josh Harrison’s pinch-hit homer gave the Pirates a lead. Pedro Alvarez hit his sixth home run and joined Russell Martin, who batted second Thursday, in reaching base four times. Andrew McCutchen hit his first homer this season, and Starling Marte scored three runs.

“You don’t want to get out,” said Jordy Mercer, who singled and scored twice in the seventh and eighth innings. “You just want to keep passing the baton.”

The Pirates exacted some measure of revenge after the Brewers swept them last weekend at Miller Park. The Pirates had lost five of their previous six games.

Harrison pinch-hit for Volquez in the seventh after Mercer singled. He tried to bunt but fouled the ball away. With a 2-2 count, he turned on a slider from Rob Wooten and hit his first home run this year down the left-field line.

“Knowing this field and being here a while, hitting it down the line, you’ve got a pretty good chance,” Harrison said. “I felt pretty good about that one coming off the bat.”

Harrison had only eight plate appearances this season before Thursday but had not reached base.

“Coming off the bench isn’t necessarily something that’s easy,” Harrison said. “You’ve got a chance to get presented with an opportunity every night. You cannot let what’s happened in the past affect you.”

The Pirates added six runs in the eighth against lefty Wei-Chung Wang, whom the Brewers selected from the Pirates organization in the December Rule 5 draft. Three of those runs came on Alvarez’s homer, an opposite-field shot. Gaby Sanchez hit a solo home run, Jose Tabata hit a pinch-hit RBI double, and Martin had a run-scoring single.

“I saw him in three instructional leagues,” manager Clint Hurdle said of Wang. “I know Wang from way back. He wasn’t able to locate the ball, which we had seen him locate a little bit.”

But before Wang arrived on the mound, the Pirates had to deal with Gallardo, who walked four in six inning and threw 114 pitches. The Pirates converted only one of those walks into a run, but the high number of pitches made it certain they would get a crack at Milwaukee’s relief corps.

“When you can push a quality starter out because of his pitch count and to throw that many pitches in six innings means you did some yard work at the plate,” Hurdle said.

Volquez, meanwhile, needed only 77 pitches through seven innings, his longest outing this season. He allowed two runs on eight hits, walked one and struck out three.

Of the 28 batters he faced, he retired 20 of them on three or fewer pitches.

“That kept me in the game longer,” Volquez said. “They didn’t get too deep in the count.”

Volquez has not walked more than two batters in any of his four appearances this season, one of many turnarounds from his poor 2013 season and the struggles he has endured since a good 2008 campaign.