On Friday night (and Saturday morning), the Orioles and Tampa Bay Rays combined for the longest game, time-wise, in both franchises’ histories, a six hour, 54-minute, 18-inning ordeal that ended on David DeJesus' single to right that gave the celebrating Rays a 5-4 win.

"Long. Devastating, obviously," Orioles third baseman Manny Machado said. "Would have been much better if we would have came out with the win. But they came [out] on top."

The Orioles are now 3-2-1 in games that have lasted at least 18 innings in their history.

The two sides kept battling in a key matchup between teams fighting for their postseason lives while setting an innings record for the Rays (16 innings had been the previous for Tampa Bay). The Orioles’ longest game, innings-wise, was a 19-inning affair on June 4, 1967, a 7-5 win over the Washington Senators.

Friday’s game lasted so long it seemed as if the Senators were in existence at first pitch. The time of game surpassed the Orioles’ previous mark of 6 hours and 15 minutes set at Philadelphia on July 2, 2004. The Rays had never been part of a six-hour contest.

The clubs also set a major league record by combining to use 21 pitchers. The marathon was particularly daunting for an Orioles club that arrived at its Florida hotel from Boston at around 3:30 a.m. Friday morning.

"It’s tough obviously, getting in at 3 and then coming here and playing extra-inning games," Machado said. "It was definitely tough, but we try to put that aside and try to win games. It didn’t work out for us today. We didn’t get key hits. We didn’t really get so many hits after the ninth inning. So we just have to put this game aside of us and come back tomorrow. I mean, we’ve got another game in a couple hours so we’re gonna have to come back and get mentally ready and keep going."

By the end of the 18th, a couple thousand people remained from the announced crowd of 21,247.

The Orioles (81-72) are now three games behind the Rays (84-69) and 2 1/2 behind the Cleveland Indians (84-70) for the second wild-card spot. Unless they sweep the next three here, the Orioles will return to Baltimore trailing the Rays with only six games remaining in 2013.

Looking to jumpstart an offense that had gone stale much of this month – the Orioles had hit .222 with runners in scoring position in their past six games while stranding 41 runners total – Showalter mixed up his lineup Friday night. He shifted Machado from second in the order to first, Adam Jones from third to second and moved red-hot Danny Valencia into the cleanup spot.

It didn’t exactly light a fire under the Orioles – they were 3-for-12 with runners in scoring position, left 13 men on base and had just two hits after the seventh inning – but the new configuration yielded two key runs in the seventh to give the Orioles their first lead.

No. 9 hitter Brian Roberts led off with a 10-pitch walk against reliever Jake McGee, who then hit Machado on the right hand with a pitch. Jones followed with a RBI double against lefty Alex Torres to tie the game at 3-3. With one out, Valencia hit a sacrifice fly to center to score the go-ahead run.

Rookie Kevin Gausman gave up the lead on an RBI single by Ben Zobrist in the bottom of the seventh. It was the first earned run allowed by the Orioles bullpen since Sept. 11th – a span of 21 2/3 innings over nine games.

The Orioles bullpen started another scoreless streak after that, thanks in part to Josh Stinson, who threw 2 1/3 perfect innings of relief and Bud Norris, who also was forced to come out of the bullpen in the club’s previous longest game this year in Arizona. Norris (10-12, 4-3 with the Orioles) lost that one and lost this one – after giving up a double to Desmond Jennings and DeJesus’ single.

Jennings who scored the game-winner, had been scratched from the starting lineup with a sore neck but got four at-bats in the game.

"Very proud [of the bullpen]," said Orioles reliever T.J. McFarland, who worked two scoreless innings before giving way to Norris. "Everyone just came out there and threw well. Everybody did. Every single person in that pen that came out today was on point, attacking hitters.

"Nobody in our pen, nobody on our pitching staff would ever deny the ball. Everybody wants the ball. That’s how I felt."

On a night that featured a combined 593 pitches, Showalter went to his bullpen first, spelling Jason Hammel to start the sixth after a spotty but ultimately solid outing.

Searching for his first win since May 27, Hammel was charged with a difficult task: Return to the place where he started his career and pitch in arguably the biggest game of the season to date. And, after being sidelined for more than a month due to injury, start for just the second time since July.

The evening started out terribly for Hammel, who allowed two doubles and a run in his first seven pitches. The Rays scored a second run when Chris Davis failed to handle a grounder to first base. Hammel induced two more ground balls, escaping a 21-pitch inning by allowing just two runs (one earned).

Tampa Bay scored again in the second when slow-footed catcher Jose Molina doubled to right and then scored on consecutive fly ball outs. He received a loud ovation from the crowd for his hustle, if not his speed.

That was the last run Hammel would allow. He retired 12 of 14 after Molina’s double. He struck out his final two batters and threw just 77 pitches (52 for strikes).

A former 10th-round draft pick of the Rays in 2002, Hammel, who spent three seasons with the Rays, incredibly had never won at Tropicana Field before picking up the victory on Opening Day this year against reigning Cy Young Award winner David Price.

Much has changed since that outing for Hammel, who began the season 7-2, but had dropped six straight decisions heading into Friday and was sidelined for more than a month due to a strained right forearm.

Friday was just his second start since coming off the disabled list and, after a rough beginning, kept the Orioles close until they could finally get some runs against Price.

Far from his best, Price allowed a baserunner in every inning he pitched. He lasted just five – his shortest outing since going five innings on Aug. 19 at Camden Yards. Similar to that game – in which Price allowed 10 hits but two runs – the hard-throwing lefty kept bending but not breaking Friday.

He was touched up for nine hits and a walk but only two runs, including a RBI ground out by Nick Markakis in the sixth after Price was replaced by Jamey Wright.

"He’s one of the aces in the game and we took him out early," Machado said. "And we were definitely excited for that."

The Orioles scored their first run on a Jones’ RBI single, though it was more good fortune than solid hitting. With the bases loaded and no outs, Jones hit a slow high-bouncing chopped halfway down the third base line that Evan Longoria couldn’t snag barehanded.

Davis then struck out and Valencia, who was 10-for-14 in his career against Price, hit into a double play.