PHOENIX -- Esmil Rogers needed a boost, so this outing came at a perfect time for the right-hander.
"I just try to do everything I can to be here," he said. "I'm going to get a couple of more opportunities to start and I have to get ready."
Rogers (4-7) struck out five and walked one in one of his best games of the season. It was his first victory since June 18 against Colorado.
The 28-year-old Rogers said the key was an effective two-seam fastball and sinker. He got 11 outs from 10 groundballs.
"I've been working on that, getting my confidence back. I got the opportunity to throw so many in the count, whenever I wanted," he said. "I was thinking about it like `Be down in the zone and everybody's going to swing at it.'"
Arizona hit into four double plays, including an inning-ending one in each of the last three frames. It managed just four hits while wasting the second complete game of the season for Brandon McCarthy (3-9), who threw 93 pitches in a five-hitter.
Edwin Encarnacion hit a two-run shot in the ninth for the Blue Jays. It was his 35th on the season.
Rogers and McCarthy locked up in an unlikely pitchers' duel. Both entered with a 5.03 ERA and three victories apiece.
Toronto jumped on McCarthy for two runs in the second, with the bottom of the lineup doing the damage. Kevin Pillar singled in Moses Sierra with two out and No. 8 hitter Anthony Gose followed with a triple off the wall in center field.
That was enough run support for Rogers, who retired 13 straight at one point.
Arizona finally chased Rogers in the seventh. Tony Campana got on with a leadoff walk and stole second. Rogers then struck out Adam Eaton before he was replaced by Sergio Santos.
Manager John Gibbons decided to pull Rogers though he had only allowed a hit and a walk while throwing 83 pitches.
"He's been vulnerable to a home run ball lately. He started scattering the ball a little bit," Gibbons said. "He's been in and out of the rotation a little bit, so all that added up, even though it was just one hit. I know him pretty good, I think."
Diamondbacks manager Kirk Gibson thought his team had chances against Rogers.
"You saw how quickly Gibbons took him out. He wasn't throwing that well," Gibson said. "He threw a good game but when you have a guy going like that, you have to try and make an adjustment on him and we didn't do that."
Santos walked Paul Goldschmidt to put runners on first and second, and then turned a double play when Eric Chavez grounded back to the mound.
McCarthy retired 16 in a row before Ryan Goins reached on a leadoff single in the ninth. Encarnacion then drove the next pitch over the wall in left, making it 4-0 and giving him 101 RBIs on the year.
"He's dangerous," Gibbons said. "Eddie's not just a slugger. Eddie goes up there with a plan. He's really a student of hitting."
The Diamondbacks rallied in the bottom half against Aaron Loup. Cliff Pennington reached on a leadoff double, advanced to third on a wild pitch and scored on Willie Bloomquist's pinch-hit single.
The Blue Jays then brought in closer Casey Janssen, who walked pinch hitter A.J. Pollock before retiring three in a row for his 27th save. He is tied with Kelvim Escobar for fifth on Toronto's career saves list.
RHP Matt Langwell, the player that completed the Diamondbacks' trade with Cleveland in which Arizona sent outfielder Jason Kubel to the Indians, reported to the team. The Diamondbacks transferred OF Cody Ross to the 60-day disabled list with a dislocated right hip to make room for Langwell on the 40-man roster. ... Pennington, who played shortstop, had to go far to his left well behind second base to get to a grounder from Gose, and still managed to throw out Gose on a very close play at first base in the fifth inning. ... RF Gerardo Parra turned in another outstanding defensive play, sliding to catch a sinking fly ball from Goins in the sixth. ... Toronto is set to call up pitchers Kyle Drabek, Ricky Romero, Jeremy Jeffress, Luis Perez and catcher Mike Nickeas from Class AAA Buffalo and have them with the Blue Jays by Tuesday. Toronto has won six of its last eight games and the pitching staff has allowed two runs or less in six of those games.