Alfonso Soriano's RBI single with one out in the bottom of the ninth sent New York to a 6-5 victory over Tampa Bay in the finale of a three-game set.
Jake McGee (2-3) walked Brett Gardner to start the final frame, and he advanced on a wild pitch. Derek Jeter was intentionally walked, but Robinson Cano fanned swinging ahead of Soriano's line smash to center that easily plated Gardner with the winning run.
Soriano finished 4-for-5 with a two-run homer, three RBI and scored twice to help New York avoid a sweep at the hands of their division rivals.
"It was a very exciting moment. In my third game back with the Yankees and to having a game-winning hit is a very special moment," Soriano said.
Activated from the 15-day disabled list prior to the contest, Jeter celebrated his return to the lineup for the first time since July 11 by going 2-for-4 with a solo homer and two runs scored.
Mariano Rivera (2-2) tossed a perfect top of the ninth for the Yankees, who got a 4-for-4 performance from Ichiro Suzuki that included a run driven in.
Wil Myers hit a solo homer and a three-run shot, scoring three times in defeat for the Rays, whose three-game win streak came to an end. Tampa dropped into second place in the AL East, one-half game back of Boston, which won at Baltimore earlier Sunday.
"It was a really well played game overall, they just got us today. The thought that kept entering my mind was how proud I was of our guys, regarding of how well we've been playing over the last month or so," said Rays manager Joe Maddon.
Jeter made a dramatic entrance at the plate, hitting a first-pitch, one-out solo shot to right against Rays starter Matt Moore in the bottom of the first inning.
"It feels good to contribute. The first of anything is difficult to get. The first hit, first homer, first RBI -- even the first game is difficult. It feels great to contribute, but more importantly we won. I wouldn't feel good if we didn't win this one," said Jeter.
The homer was the Yanks' first since the All-Star break and first by a right- handed batter since June 25.
Cano and Soriano then singled to put runners on the corners, and a Vernon Wells fly to center made it 2-0. A wild pitch moved Soriano to second, and he scored on Suzuki's single to center.
Tampa hit the scoreboard in the second on Kelly Johnson's double to score Myers, then moved ahead in the third as Evan Longoria and James Loney singled with one out ahead of Myers' blast to left for a 4-3 contest.
Jeter singled over Johnson's glove at second to start the home third, advanced on a Moore balk and scored on Soriano's two-run homer to right which just eluded Myers' glove at the right-field wall.
Myers drew the Rays even, starting the fifth with a homer to right. It was the 22-year-old's first career multi-homer effort.
New York failed to take the lead despite two on in the seventh, and couldn't get a runner from second home in the following frame.
Moore ended up working five innings, allowing five runs on eight hits with three strikeouts, while counterpart Phil Hughes was charged with nine hits and five runs in just four-plus frames ... Moore was bidding to become the youngest pitcher to reach 15 wins before Aug. 1 since Greg Maddux did it with the Cubs in 1988 when he reached that mark on Aug. 1 at the age of 22 ... Prior to the game, former outfielder and 2009 World Series MVP Hideki Matsui signed a one-day minor-league contract to retire as a member of the Yankees ... The Rays have never swept a series of three-or-more games vs. the Yankees in the Bronx ... On Sunday, former Yankees owner Colonel Jacob Ruppert was posthumously inducted to the National Baseball Hall of Fame after receiving election by the Pre-Integration Era Committee.