Updated

Evan Longoria has developed a knack for going deep in the final game of the regular season.

Longoria hit three home runs and the Tampa Bay Rays beat Baltimore 4-1 Wednesday night, ending the Orioles' bid to force a one-game tiebreaker for the AL East title.

Longoria finished the season with a bang for the second straight year, hitting solo shots off Chris Tillman in the first and fourth innings before adding another solo shot off Jake Arrieta in the sixth.

"It was cool," Longoria said. "That's about as fun a night you can have in a ballgame. Tonight was fun."

With a chance to tie the major league record of four homers in a game, Longoria grounded out in the eighth.

Longoria's second career three-homer game came a year after the three-time All-Star hit two of them on the final night of last season, including a 12th-inning shot that clinched a postseason berth. His bid for the first four-homer game in franchise history ended when he grounded out against Pedro Strop in the eighth.

In four season finales, Longoria is 8 for 15 with six homers and eight RBIs in his career.

Ryan Roberts also homered for the Rays in the fourth against Tillman (9-3).

"I just think it highlights how well we play in games 162," Tampa Bay manager Joe Maddon said with a smile. "It was a very dramatic game tonight, the way it all unfolded. I just like the idea that we played the last game of the season with that kind of effort and intensity."

Rays center fielder 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 when he was removed for a pinch runner in the eighth inning.

An emotional Upton had tears in his eyes in the dugout after leaving the game.

"This is all I know," Upton said. "There's the possibility that I won't be back."

The loss on the final day of the regular season left the Orioles as a wild-card team. They'll play Friday at Texas, with the winner advancing to the division series.

Baltimore began the day one game behind the New York Yankees in the division. The Orioles needed a win plus a loss by the Yankees against Boston to pull even.

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.

"It's a little bit disappointing to be going home," Longoria said. "We're playing our best baseball now."

Hellickson allowed three baserunners, two of them in the fourth inning when Jones singled to right-center 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 was replaced by McGee after getting the next batter, Nate McLouth, to pop out.

NOTES: Longoria has homered in five of his last seven plate appearances in the final game of the regular season. ... Rodney finished with a 0.60 ERA, which set a major-league record for a relief pitcher (50 innings or more). Oakland RHP Dennis Eckersley had held the record with a 0.61 ERA in 1990.