ST. PETERSBURG, Fla. (AP) -- Tampa Bay Rays manager Joe Maddon was more than happy to wait until the early morning hours for what he called an incredible victory.
David DeJesus ended a nearly seven-hour game with a one-out RBI single in the 18th inning, and the Tampa Bay Rays took over sole possession of the top AL wild-card spot by beating the Baltimore Orioles 5-4 on Friday night.
''Obviously, both teams really battled extremely hard,'' Maddon said. ''You know both teams wanted to win it badly. To win that game means a lot based on the time of the year that it is.''
Tampa Bay started its game at 7:11 p.m., tied with Texas atop a crowded race for the two AL wild cards. By the time it ended 6 hours, 54 minutes later - a record in time for both teams - the Rays were a half-game ahead of Cleveland, which beat Houston 2-1 in a rain-shortened game. The Rangers lost to Kansas City 2-1 and dropped a half-game behind. Baltimore is 2 1/2 back.
''That's everything right there that you play 162 games for,'' Tampa Bay's Chris Gimenez said. ''I've never been a part of a game that long. To win it, especially how we did it, I hope this is something we can take and kind of run with. It couldn't happen at a better time, I'll tell you that much. It's a huge win for us. The only thing we can control is how we go out and play. If we win, we're in. Got that Al Davis mentality, 'Just win baby.'''
Desmond Jennings had a one-out double in the 18th off Bud Norris (10-12) - the Orioles' 10th pitcher and one of a big league-record 21 used in the game.
After Yunel Escobar walked, DeJesus won it on his line single to center, ending the Rays' longest game in franchise history and setting off a wild celebration. Luke Scott of the Rays came onto the field wearing a Chewbacca mask, while Jamey Wright dressed like a member of the rock band Kiss.
Now the AL East rivals get to do it all over again at 1:05 p.m. Saturday.
The Miami Marlins beat the New York Mets 2-1 in 20 innings earlier this season, the longest game by innings in three years. That game only took 6 hours, 25 minutes.
Jeremy Hellickson (12-9), Sunday's scheduled starter, allowed one hit in 2 1-3 innings of relief.
Maddon said a decision on who will pitch Sunday has not been made.
Ben Zobrist drove in the tying run in the seventh with an RBI single off Kevin Gausman after the Rays blew a 3-2 lead in the top half.
Adam Jones greeted reliever Alex Torres with an RBI double and Danny Valencia had a sacrifice fly to give Baltimore the temporary lead.
After Zobrist tied it, the teams traded zeros long into the night.
From the eighth inning on, the Orioles had just two hits. The Rays had six.
''Two teams wanted something very baldy and that's why those game go on like that,'' Orioles manager Buck Showalter said. ''The game's not always fair that night, but it usually evens out. We're all operating under the same umbrella and it's part of the job description that you know, going in, there's going to be some times that will be challenging.''
Tampa Bay loaded the bases with two outs in the 15th, but failed to score when Tim Beckham was retired on a hard grounder to second.
The Rays grabbed a 2-0 advantage in the first. Zobrist had an RBI double and later scored when first baseman Chris Davis was charged with an error for misplaying Matt Joyce's grounder.
Tampa Bay went ahead 3-0 during the second when slow-footed catcher Jose Molina doubled, went to third when Escobar hit a fly ball and scored on DeJesus' sacrifice fly. Molina received a standing ovation after scoring.
Orioles starter Jason Hammel, winless in his last 12 starts since beating Washington on May 27, gave up three runs and six hits over five innings. Tampa Bay left-hander David Price, who has gone five starts without a victory, allowed two runs and nine hits in his five-plus innings.
''Devastating obviously,'' Orioles third baseman Manny Machado said. ''It would have been much better if we had come out on top.''
NOTES: There were 593 pitches, 301 by the Rays and 292 by Baltimore, thrown in the game. ... Machado got hit around right hand by Jake McGee's pitch in the seventh, but remained in the game. ... Jennings was a late scratch due to neck stiffness. He had a pinch-hit infield single in the 9th and stayed in the game to play center. ... Tampa Bay recalled RHP Jake Odorizzi from Triple-A Durham.