J.J. Hardy and Michael Bourn came through with RBIs in the eighth inning, and Baltimore rallied from a four-run deficit to beat Tampa Bay 5-4 on Friday.
The final out came when Mike Mahtook was cut down at the plate trying to score from first base on a single into the left-field corner by Alexi Ramirez.
Pedro Alvarez and Chris Davis homered for the Orioles, who began the day two games behind first-place Boston in the AL East and tied with Toronto for the two AL wild cards.
Down 4-0 in the second inning, Baltimore closed to 4-3 before completing the comeback in the eighth against wild reliever Brad Boxberger (4-2).
Two walks and a hit batter loaded the bases for Hardy, who tied it with an infield single. Bourn followed with a fly ball to left field, and pinch-runner Nolan Reimold easily scored as the throw was cut off.
Brad Brach (9-3) worked the eighth and Zach Britton got three outs for his 44th save in 44 tries.
Evan Longoria hit his career-high 34th homer and Richie Shaffer also connected for the last-place Rays.
Tampa Bay starter Chris Archer allowed three runs in 6 1/3 innings and struck out four to increase his AL-leading total to 221. The 18-game loser also avoided setting a franchise record for losses in a season.
Archer was replaced after giving up successive one-out singles in the seventh. Danny Farquhar hit Adam Jones with a pitch to load the bases for Hyun Soo-Kim, who hit a deep liner to center. Kevin Kiermaier leaped with his back to the 7-foot wall, grasped the ball and brought it back onto the field before it popped from his glove.
Kim was limited to an RBI single, and Farquhar struck out Manny Machado and Davis.
But Baltimore would not be denied in the eighth.
Longoria homered off Ubaldo Jimenez with a man on in the first inning and Shaffer went deep in the second for a 4-0 lead.
Jimenez settled after that. The right-hander gave up four runs over seven innings, striking out eight.
Alvarez hit his 21st home run in the second and Davis delivered No. 38 in the fourth. Davis also struck out twice and has 201 for the year.
Baltimore’s Mark Trumbo, the major league home run leader with 42, was sidelined with back spasms. It was only the second game he’s missed this season.
Notes: Brad Miller usually plays shortstop or first base for the Rays. In an effort to gauge Miller’s versatility and add flexibility to the roster, Rays manager Kevin Cash started him in left field. It didn’t take long for Miller to get noticed: The second Baltimore batter of the game hit a pop to left that glanced off Miller’s glove for an error. ... Nick Franklin, who strained his hamstring on Thursday, was held from the game. Cash listed him day-to-day.
Who: Tampa Bay (63-84) at Baltimore (81-66)
When: Saturday, 7:05 p.m.
Where: Camden Yards, Baltimore
Probable pitchers: Matt Andreise (7-7, 4.46) vs. Chris Tillman (16-5, 3.68)
Radio: 620 AM