Most important, the win cut the Rays' magic number to earn an American League Wild Card berth to two games.
By reaching 90 wins, the Rays hit that mark for the fourth consecutive season. That will be the longest such streak in the Major Leagues unless the Rangers win 90 as well.
"That's outstanding, it's a great tribute to the entire organization, from top to bottom," manager Joe Maddon said. "It really is significant."
After three scoreless frames, Wil Myers greeted Yankees starter Ivan Nova with a single to start the fourth. James Loney then walked before Evan Longoria singled to left to score Myers for a one-run lead.
Delmon Young homered to deep center off Nova to lead off the seventh. Young's second home run since joining the Rays on Sept. 1 pushed the lead to two runs.
"I just put a good swing on a pitch out over the plate, just trying to swing at pitches that are going to be more out over the plate than on the corners," Young said.
The way Cobb was pitching, the Rays didn't appear to need much more.
Cobb has been the Rays' most consistent starter down the stretch. On Thursday night he picked up where he left off after notching his 11th win of the season on Saturday, against the Orioles.
The 25-year-old right-hander threw seven scoreless innings before the Rays batted in the eighth.
"Actually, I struggled in the beginning of the game with a lot of things, my fastball location, my changeup mostly," Cobb said. "When you have those games, you have to try and fight it, compete it, and know that you've got to minimize the amount of pitches if you want to work deep into the game. It's a difficult task. But obviously, I settled down a little bit. I was able to get some quick outs and work deeper in the game."
Longoria added a two-run single off Dellin Betances in the eighth that pushed the lead to four runs. After Betances walked David DeJesus, the crowd of 48,675 got what they wanted, as Mariano Rivera entered the game. Even the Rays' dugout emptied onto the field to cheer for the retiring closer, who was making his final appearance at Yankee Stadium.
"Amazing," said Rivera of the Rays' tribute. "It has been happening the whole year. Seeing the guys again when I came out, and still after the game, being up for me, it has no price. I appreciate that. It's humbling to myself, being able to finish the way the Lord allowed me to finish. It was spectacular. Thank God for that."
Rivera got the final two outs of the inning to end the threat.
The Yankees finally got something going against Cobb in the eighth, when Curtis Granderson doubled to lead off the inning. Lyle Overbay then singled to right to put runners at first and third with no outs.
Joel Peralta took over for Cobb and struck out Zoilo Almonte. Pinch-hitter Vernon Wells then swung and missed at a 3-2 pitch for the second out before J.R. Murphy popped out to center field to end the inning.
"That was unbelievable," said Cobb about Peralta's escape act. "You come out of a game in that situation, and you think the worst. However it may happen, you just consider those two runs scoring and you're pretty upset, because you had a 4-0 lead, and it could be possibly 4-2, but the way he stepped up and didn't allow one run in was absolutely amazing."
Cobb has now defeated the Rangers, Orioles and Yankees in order.
"He pitched extremely well once again," Maddon said. "Curveball outstanding, changeup -- I think he was having a hard time command-wise with the changeup early. … Then he started using his fastball more, which I thought was a great move. But overall, a fantastic performance."
The Rays' clubhouse was a festive place after the game. They won the game, they witnessed history with Rivera's touching farewell and, as happens every year, the rookies dressed in bizarre costumes -- including Myers in what looked to be a large stuffed diaper -- for the trip to Toronto.
"I didn't think today could go any better for us as far as the outcome of the game," Longoria said. "Being able to experience that whole thing and having the rookie dress-up on the same day, it's like we got the trifecta today."