Cliff Floyd began the 11th with a single and pinch-runner Jonny Gomes stole second before Gross delivered the winner up the middle on a 1-1 pitch. Rivera (0-1) had not allowed a run in 14 previous appearances.
J.P. Howell (3-0) pitched two scoreless innings for the win, the Rays' 15th in 20 games. Tampa Bay has won a club-record 11 straight at home and is a half-game ahead of Boston in the AL East after the Red Sox lost 5-4 at Baltimore. It's the first time the Rays have sat alone atop the division standings beyond the first week of a season.
At 23-16, the Rays are seven games over .500 for the first time in the team's 11 seasons. They've finished last nine times in the past decade.
The Rays were two outs away from victory when Hideki Matsui hit his first homer since April 15, a stretch of 57 at-bats, into the right-field seats off closer Troy Percival to send it to extra innings.
Eric Hinske drove in Tampa Bay's first run with a two-out, fourth-inning single off Chien-Ming Wang, who allowed one run and seven hits in seven innings. The Yankees starter walked three and struck out two.
Rays starter Edwin Jackson scattered five hits over seven innings before leaving a 1-0 lead to the bullpen. Dan Wheeler worked a scoreless eighth, but Percival couldn't finish off the Yankees.
The keys to the surge have been strong starting pitching, improved defense and timely hitting, such as Hinske's RBI single after Carlos Pena led off the bottom of the fourth with the only extra-base hit off Wang.
Matt Garza pitched seven scoreless innings in Monday night's 7-1 win over the Yankees, and Jackson took up where he left off to beat New York for the second time. He won 6-3 at Yankee Stadium on April 5 and pitched poorly 10 days later in a 5-3 loss to the Yankees at Tropicana Field.
Jackson's performance has been all over the board this season. He was 2-0 with an 0.64 ERA in his first two starts, then 0-3 with a 5.72 ERA over the next five outings to raise questions about whether he should remain in the rotation.
He entered Tuesday night looking for his first win since beating Seattle on April 10, but was coming off throwing eight scoreless innings against Toronto last week in a game Tampa Bay eventually won 8-3 in 13 innings.
The Yankees threatened in the second, sixth and seventh innings against the Rays starter, but stranded runners at third all three times.
Robinson Cano hit into a force play and Alberto Gonzalez grounded into a double play after Jackson gave up singles to Jason Giambi and Melky Cabrera in the second. Bobby Abreu and Matsui failed to come through after a diving Hinske played what should have been a single to right into Derek Jeter's one-out triple in the sixth.
Pinch-hitter Shelley Duncan took a third called strike, ending the seventh after Cabrera moved from second base to third on a wild pitch.