The Rays began the final day of the regular season tied with Texas for the second wild-card slot. Both teams trailed Cleveland by one game for the top spot.
Cleveland played at Minnesota and the Rangers hosted the Los Angeles Angels.
Longoria hit an RBI double as the Rays used their highest-scoring first inning since 2010 to go ahead early. Tampa Bay took a 7-0 lead into the sixth before Toronto rallied.
Rays manager Joe Maddon was ejected in the seventh and the Blue Jays put the go-ahead run at the plate in the eighth and ninth innings. Fernando Rodney got for four shaky outs for his 37th save in 45 chances.
Tampa Bay is certainly familiar with big rallies on the final day. In 2011, the Rays overcome a 7-0 deficit in the eighth and came back to beat the Yankees 8-7 in 12th to clinch a wild-card spot.
This time, the Rays almost let a huge lead slip away.
Matt Moore (17-4) won consecutive starts for the first time in more than two months. He allowed three runs and six hits in 5 1-3 innings. Moore walked three, all in the first inning, and struck out four.
Blue Jays starter Todd Redmond (4-3) got just two outs.
The Rays looked to have robbed much of the drama from the final day by batting around in the first. Jose Lobaton hit a two-run double and James Loney, Delmon Young and Yunel Escobar had RBI singles.
Tampa Bay made it 7-0 in the fourth when Myers hit an RBI double that eluded Blue Jays outfielder Kevin Pillar.
Toronto broke through against Moore in the sixth when Mark DeRosa hit a two-run double. Moore left after Ryan Langerhans singled, and reliever Jake McGee gave up a sacrifice fly to J.P. Arencibia.
The Blue Jays cut it to 7-4 in the seventh on Brett Lawrie's double. Joel Peralta replaced McGee and walked Moises Sierra to load the bases.
Maddon was ejected by home plate umpire Paul Schrieber for arguing, but Peralta escaped when pinch-hitter Adam Lind grounded the first pitch he saw into an inning-ending double play, with first baseman Loney making a superb catch on shortstop Escobar's low relay throw.
Peralta ran into trouble again in the eighth, leaving with two outs and runners at first and second. Rodney came on and gave up RBI singles to Jose Reyes and Anthony Gose, shaving Tampa Bay's lead to 7-6. Lawrie walked to load the bases before Rodney struck out Sierra.
NOTES: It was the Rays' highest-scoring first inning since Sept. 10, 2010, when they also scored six in a game at Toronto. ... Toronto RHP Esmil Rogers pinch-ran for Lind (back) after Lind's leadoff single in the ninth. Rogers was forced at second on Langerhans' grounder. ... Maddon was ejected for the fifth time this season. ... The Blue Jays played a video tribute to LHP Darren Oliver, who is set to retire after 20 seasons. Players from both teams stood and applauded when Oliver took the mound to begin the seventh. ... Toronto drew 44,551 fans in their finale for a season total of 2,536,562, their highest since 1997.
More Sports Headlines
Mariners beat Twins 4-3 in 11 innings Snohomish mixed martial artist returns to her first love AquaSox strand 10, fall 3-2 to Volcanoes Seahawks release DT McDaniel , acquire CB Seisay Benches empty as Royals fall to Blue Jays Rays demote Moore, place Souza on DL with fractured hand Charles scores 29 points, Liberty beat Storm 78-62 Park wins Women's British Open, captures 4th different major
Our new comment system is not supported in IE 7. Please upgrade your browser here.