ST. PETERSBURG -- Buck Showalter shook up his batting order Friday night and the Orioles responded with 12 hits, but that wasn't enough as the Rays tightened their grip on one of the two American League Wild Card spots with a 5-4 win over the O's in 18 innings.
The Orioles trail the Indians by 2 1/2 games for the second AL Wild Card. Tampa Bay holds the top spot.
The two teams combined to use a Major League-record 21 pitchers. At six hours and 54 minutes, it was the longest game in Rays history, both in terms of innings and time, and the longest game in Orioles history in terms of time.
There was a playoff atmosphere at Tropicana Field as 21,247 turned out to see the game. David DeJesus finally ended it with a single off Bud Norris that scored Desmond Jennings.
"It was a case of two teams both wanting something really bad," said Showalter. "And there was a small margin.
"I'm really proud of everybody. We didn't give in. But things are not always fair. They're battling, too. We're all operating under the same umbrella."
"It was long, long," said Manny Machado, who played all 18 innings and went 1-for-7 while batting leadoff for the first time in his professional career. "It would have been much better, obviously, if we had come out on top. But they're trying to win just like we were.
"Now we've got another game in a couple of hours and we have to come back and try to win," added Machado, who was hit on the right hand by a pitch in the seventh inning, but remained in the game.
In the seventh, Adam Jones, moved from cleanup to second in the order, doubled off the left-field fence to drive home Brian Roberts, who had walked, to tie the score at 3. Danny Valencia, batting cleanup for the first time as an Oriole, put Baltimore on top for the first time by scoring Machado with a sacrifice fly to center.
But the Rays tied it up with a run off Kevin Gausman in the bottom of the seventh.
Jason Hammel, making just his fourth start since the All-Star break and starting on six days' rest, worked the first five innings, allowing three runs on six hits. Hammel, who was drafted in the 10th round by the Rays in 2002, was making his second start and third appearance since his five-week stint on the disabled list because of a flexor strain. Hammel was the first of 10 Baltimore pitchers to appear in the game.
David Price, the first of 11 Rays pitchers, shut the Orioles out for the first four innings. But the Birds loaded the bases with a walk to Michael Morse and singles from Roberts and Machado to start the fifth. Jones' slow chopper down the third-base line pushed one run across the plate and left the bases loaded. But Chris Davis struck out and Valencia bounced into an inning-ending double play.
The Orioles chased Price in the sixth when Matt Wieters led off with a double -- the Birds' ninth hit off the Rays' ace left-hander. Wieters later scored on Nick Markakis' infield grounder to make it 3-2.
The Rays scored a run in the first on back-to-back doubles by DeJesus and Ben Zobrist. Following a single by Evan Longoria, Zobrist crossed the plate courtesy of a two-base error by Davis at first. Tampa Bay added another run in the second when catcher Jose Molina legged out a double and scored on DeJesus' sacrifice fly. But Hammel, who was 1-2 with a 5.57 ERA in four previous starts against the Rays, settled down after that and limited Tampa Bay to two hits over the next three innings.
Jim Hawkins is a contributor to MLB.com. This story was not subject to the approval of Major League Baseball or its clubs.