ST. PETERSBURG, Fla. (AP) This wasn't the finish that Adam Jones and the Baltimore Orioles needed.

Pinch-hitter Brandon Guyer led off the ninth inning with a tying homer and Kevin Kiermaier beat out a two-out single for the winning run as the Tampa Bay Rays rallied past the Orioles 7-6 Sunday.

Chris Davis hit his major league-leading 43rd homer for the Orioles, who lost for the fourth time in 12 games. Baltimore fell 5 1-2 games behind Houston for the second AL wild card.

More from FoxSports

''I have to be optimistic or what's the reason for me coming here and playing?'' said Jones, their star center fielder said. ''If I think we're done, I should just pack up my whole locker and go home. Till that day happens, I always think that we have a chance.''

Baltimore would have to jump over four teams to make the playoffs.

''Gloom and doom, we don't do that,'' Orioles manager Buck Showalter said. ''We're going to try and win the rest of our games and make it tough on everybody.''

Trying for his 35th save, Zach Britton (4-1) instead let a 6-5 lead get away and wound up with his fourth blown chance.

''It's going to be a frustrating flight home,'' he said.

After Guyer homered, Evan Longoria hit a one-out triple. Logan Forsythe was intentionally walked, Richie Shaffer drew another walk to load the bases and Joey Butler struck out. Kiermaier followed with a slow roller to second and hustled for a hit.

''I made just enough contact where I hit it straight down and I didn't hit it hard enough to where they could make a play on me, and I'll take that any day of the week,'' Kiermaier said.

Kirby Yates (1-0) got two outs in the ninth for the win.

Longoria had Paul Janish's two-out grounder in the eighth go between his legs at third base for a two-base error that allowed Steve Pearce to score from first base. Gerardo Parra's RBI single made it 6-4.

Tampa Bay pulled within 6-5 on pinch-hitter Asdrubal Cabrera's sacrifice fly later in the eighth.

Forsythe gave the Rays a 4-3 lead with his three-run homer in the fifth. It was his fourth hit in five career at-bats against Kevin Gausman.

The Orioles tied it at 4 when Janish ended Jake Odorizzi's day on a sixth-inning RBI single.

After Manny Machado hit an RBI single, Davis made it 3-1 on his opposite-field drive into the left-field stands during the third.

TRAINER'S ROOM

Orioles: RHP Miguel Gonzalez (right shoulder) threw off a bullpen mound.

Rays: LHP Jake McGee (left knee) threw 32 pitches in his second simulated game and might return this week. ... C Curt Casali (hamstring) caught McGee and said he is not quite ready to return. ... LHP Xavier Cedeno, out since Sept. 5 with left side soreness, retired Davis on a ninth-inning grounder.

OLD TEAMMATES

Rays OF Mikie Mahtook went 0 for 3 against Gausman, who was his teammate at LSU. They played together in 2011 when Mahtook was a junior and Gausman was a freshman.

NUMBERS GAME

Orioles 2B Jonathan Schoop went 0 for 4 and had his career-best 11-game hitting streak end. ... The Rays are 2-62 when trailing after eight innings. ... Baltimore is 60-2 when ahead after eight. ... Cabrera has 500 career RBIs.

UP NEXT

Orioles: RHP Ubaldo Jimenez (11-9) will go against Washington LHP Gio Gonzalez (11-7) in the opener of a three-game interleague road series Monday night. The Orioles lost two of three to the Nationals July 10-12.

Rays: RHP Chris Archer (12-12) needs 1 2-3 innings in his start Monday night at Boston to reach 200 innings in a season for the first time. The Red Sox starter is LHP Eduardo Rodriguez (9-6).