TORONTO — If the Yankees had lost to Toronto on Wednesday, they would not have been eliminated from the race for a postseason berth. It certainly would have felt that way, though.

So when the Yankees rallied for four runs in the eighth inning, with the former Blue Jay Vernon Wells striking the key blow, and held on for a nerve-rattling 4-3 victory, they felt their season had been saved.

“For now, yeah,” Wells said.

Although there was still much work to be done, the Yankees’ agonizing four-game losing streak was over, and an energetic buzz surrounded them after the game.

In the clubhouse, Brendan Ryan, who led off the eighth with a double, held up his iPhone so he and Alfonso Soriano could watch the ninth inning of Baltimore’s victory over Boston, a game that had a bearing on the Yankees’ fortunes. Andy Pettitte laughed as he gathered teammates to take stock of Alex Rodriguez’s preppy outfit, and all around, the players and the coaches breathed a sigh of relief.