PITTSBURGH (AP) -- Arizona Diamondbacks manager Kirk Gibson was looking for a spark.
His team was coming off what he called its worst game of the season.
So Gibson moved outfielder David Peralta into the second spot of the batting order. He responded with three hits, including a two-run homer, and four RBIs as the Diamondbacks beat the Pittsburgh Pirates on Thursday night to avoid a series sweep.
"I moved him up in the lineup because he's put the bat on the ball and he's been very consistent for us," Gibson said. "He's very aggressive and he will play anywhere you ask him."
Peralta was more ready for the chance than even his manager might have known.
"We had a little team meeting among the players after (Wednesday night's 5-1 loss) and just said to remember that we are a good team," he said. "I think it motivated everybody. It left everybody with a good feeling."
Arizona scored three runs in the sixth and put the game away with seven in the ninth.
"The first game was devastating because they came back and stole it for us and then we played our worst game of the year last night," Gibson said. "We came back with a good effort today, played a good, clean game, got good pitching, some clutch hits then were able to have some fun in that last inning."
The Pirates are 0 for 8 in chances to sweep opposing teams this season. They looked primed to get their first sweep as starter Vance Worley retired the first 12 batters he faced and carried a no-hitter into the sixth inning.
Ender Inciarte broke up Worley's no-hit bid with an RBI single with one out in the sixth. Peralta followed with his third home run of the year which barely cleared the 21-foot-high fence in right field and gave Arizona a 3-2 lead.
After a strikeout and groundout against Worley in his first two at-bats, Peralta was prepared for his third trip to the plate.
"I thought `I'll get him next time,'" Peralta said. "The next time, he gave me a pitch I could hit. My whole approach is always to wait for my pitch and that's what I did in that at-bat."
Miguel Montero was the first Diamondback to reach base after he worked a leadoff walk in the fifth.
Pittsburgh scored in the third on a double by Jordy Mercer and RBI groundout by Gregory Polanco.
The Pirates opened the fourth with hits by Neil Walker, Russell Martin and Ike Davis to extend their lead to 2-0. Walker started the inning with a double and scored on Davis' single.
Brandon McCarthy (3-10) was pulled in the sixth after issuing a two-out walk to Davis. He threw 5 2-3 innings and allowed two runs and eight hits, walked two and struck out six as he needed to work through some issues on the mound in the early stages of his start.
"Some starts you feel great out of the gates but it wasn't quite there for me," McCarthy said. "I was able to hang in there and when things got dicey, I was able to make pitches."
Pirates manager Clint Hurdle was pleased with his team's overall approach against McCarthy but acknowledged the inability to capitalize on extending the lead when Pedro Alvarez grounded into a double play in the fourth inning.
"The double play in the fourth cut down some momentum we were building," Hurdle said. "We got one run in, first and second with no outs, he was able to get through that and cut off that inning. We didn't score another run the rest of the game."
Worley (2-1) went seven innings and gave up three runs, four hits and two walks. He struck out six while taking his first losing decision as a Pirate.
"Early on I was able to get ahead in the count, throw strikes and make them swing," Worley said. "And then as the game continued on I lost command of the two-seam fastball and was getting behind. The one inning, one pitch."
Arizona sent 11 batters to the plate in the ninth and scored seven runs on eight hits. Pittsburgh reliever Ernesto Frieri gave up five hits to the six batters he faced and all of them scored.
Frieri was pulled after recording just one out for Jeanmar Gomez, who entered with the bases loaded and allowed all three inherited runners to score before being charged with two runs of his own.
"We some good at-bats early, hit three rocket shots in the second inning that we didn't have anything to show for," Gibson said. "Our guys stayed with it, kept the pressure on and finally got a couple of big hits."
NOTES: A replay review of 4:13 overturned a safe ruling as Polanco attempted to steal second base in the fifth inning. ... Starling Marte singled in the third and has reached base in all 13 of his career games played against Arizona. ... Arizona sends RHP Josh Collmenter (7-4, 3.74 ERA) against RHP Ervin Santana (6-5, 4.05 ERA) as the Diamondbacks continue their trip in Atlanta. ... Pittsburgh opens a three-game series against Philadelphia when RHP Gerrit Cole (6-4, 4.02 ERA) matches up against RHP Roberto Hernandez (3-7, 4.26 ERA).