The loss on the final day of the regular season left the Orioles as a wild-card team. They'll play Friday night at Texas, with the winner advancing to the best-of-five division series against the New York Yankees.
Baltimore began the day one game behind the Yankees in the division. The surprising Orioles needed a win, plus a loss by the Yankees to Boston, to pull even.
New York cruised to a 12-2 rout of the Red Sox and finished two games ahead of the Orioles, earning its 13th division crown in 17 years. The Yankees had a 10-game lead on July 18, but Baltimore caught up Sept. 4 and the teams were tied 10 times in September.
Longoria finished the season with a bang for the second straight year, hitting solo shots off Chris Tillman in the first and fourth innings and adding another solo shot off Jake Arrieta in the sixth.
With a chance to tie the major league record of four homers in a game, Longoria grounded out against Pedro Strop in the eighth.
Longoria's second career three-homer game came a year after the three-time All-Star hit two of them of the final night of last season, including a 12th-inning, game-ending shot that clinched a post-season berth.
Ryan Roberts also homered for the Rays in the fourth against Tillman (9-3).
Jeremy Hellickson (10-11) allowed one hit — Adam Jones' fourth-inning single — in 5 1-3 innings. Jake McGee, Wade Davis, Joel Peralta and Fernando Rodney teamed to hold the Orioles to two hits — J.J. Hardy's double and Matt Wieters' single, both in the ninth inning — the rest of the way.
Jones ruined Tampa Bay's shot at a 16th shutout with a sacrifice fly off Peralta. After Wieters singled, Rodney was summoned to get the final out for his 48th save in 50 opportunities.
Chris Davis, who tied an Orioles record when he homered for the sixth straight game on Tuesday night, went 0 for 4 with three strikeouts.
Longoria is 6 for 12 with three homers lifetime against Tillman, who lasted five innings and allowed three runs and four hits in his first loss since Kansas City beat him on Aug. 11. The right-hander who had gone 3-0 with a 1.20 ERA over his previous five starts also allowed three homers in that game, matching his career high.
The Rays won 12 of 14 down the stretch, remaining in contention for the second AL wild card until the 160th game and finished with at least 90 wins for the third season.
Hellickson allowed three baserunners, two of them in the fourth inning when Jones singled to right-centre after Davis struck out on a wild pitch that allowed the Orioles outfielder to reach first. The 2011 AL Rookie of the Year walked Manny Machado leading off the sixth and replaced by McGee after getting the next batter, Nate McLouth, to pop out.
NOTES: Jones played in all of the Orioles' 162 regular-season games this season. "It's a pretty cool thing," Baltimore manager Buck Showalter said. Jones is the first Baltimore player to accomplish the feat since Miguel Tejada in 2006. ... Orioles RHP Steve Johnson (sore left knee) said he felt great after throwing off a bullpen mound. ... Rays CF B.J. Upton, who will become a free agent this winter, singled in what may have been his last at-bat with Tampa Bay. The crowd of 17,909 gave him a standing ovation from the crowd of 17,909 when he was removed for a pinch runner in the eighth inning.