TORONTO -- Vernon Wells doubled in two runs to key a four-run eighth inning as the New York Yankees snapped a four-game losing streak on Wednesday with a 4-3 comeback win over the Toronto Blue Jays.

Left-hander David Huff (3-1) allowed one run in 3 2-3 innings of relief to pick up the win. Mariano Rivera -- who is retiring at the end of the season -- pitched 1 1-3 innings to earn his 44th save of the season.

Toronto (69-82) took a 3-0 lead into the eighth inning on the strength of home runs in the fourth inning by Colby Rasmus and Ryan Goins, the first of his major-league career.

Left-hander J.A. Happ had a strong start for the Blue Jays, striking out seven over seven innings. He was removed for left-hander Aaron Loup after Brendan Ryan led off the eighth with a double to start the Yankees rally.

Curtis Granderson followed up Ryan's hit with a single and right-hander Steve Delabar replaced Loup and struck out Alex Rodriguez. Robinson Cano then singled in a run and Alfonso Soriano doubled in another run.

That set the stage for former Blue Jay Wells to double in two runs and give the Yankees a 4-3 lead.

Rivera retired Brett Lawrie on a grounder to end the bottom of the eighth after Rajai Davis singled against David Robertson and stole second.

Adam Lind led off the ninth against Rivera with a single and Kevin Pillar pinch ran for him.

Colby Rasmus followed with a single to move Pillar to second.

Munenori Kawasaki batted for Moises Sierra and his attempt at a sacrifice bunt resulted in a force at third.

Goins moved the runners to second and third with a grounder to bring up J.P. Arencibia. Arencibia's 0-for-15 slump continued as he struck out to end the game.

New York entered Wednesday's game 3 1-2 games out of an American League wild card spot and has split the first two of a three-game series with the Blue Jays. Toronto has lost six of its past eight.

It was Happ's longest outing since he went seven innings on Aug. 12 in a no decision against Oakland.

Yankee starter Phil Hughes allowed four hits, including one home run, and two runs in 3 1-3 innings and has not won since July 2.

Toronto took a 3-0 lead with one out in the fourth on two homers.

Rasmus hit a 2-1 pitch to right with one out for his fourth homer since returning from the disabled list on Sept. 13. His 22nd homer of the season scored Brett Lawrie who led off with a double.

Huff replaced Hughes and gave a two-out homer to Goins, the first of his major-league career, on a 3-2 pitch.