OAKLAND, Calif. — This time, the Rays walked off smiling.
After losing on the final pitch Saturday and Sunday, the Rays on Monday flirted with what would have been a franchise-first third straight walkoff loss.
But reliever Jason Hammel kept them in the game, rookie Evan Longoria put them ahead with a two-run homer in the 13th inning and Troy Percival finished it off for a wild 7-6 victory that ended shortly after 2 a.m. Tampa Bay time.
"I couldn't help but think about how the last two ended," Longoria said.
Having dropped out of first place after back-to-back walkoff losses in St. Louis over the weekend, the Rays (26-19) stayed one game behind the Red Sox, who won their fourth straight Monday behind Jon Lester's no-hitter.
Hammel pitched three scoreless innings to get the win.
The Rays were four outs from victory when James Shields, who battled through a rough start, allowed the A's to tie it at 5 in the eighth, and it stayed that way until the 13th.
The Rays didn't get a baserunner in the ninth, 10th or 11th innings, but hung in as J.P. Howell, working a third straight game for the first time in his career, and Hammel, pitching for the first time in 10 days, navigated Oakland threats.
It was a particularly rewarding performance by Hammel, who received a "hang-in-there" pep talk from manager Joe Maddon before the game.
"Basically he came out and said, 'How are you feeling, I said I was pretty d--- near insanity right now because I'm thinking I'm trying to get in there every day.' But he said stay ready, you're going to be a big part of us, and tonight I was a big part.
"I'm just trying to keep myself ready, and tonight I was fortunate to get in there."
It was a difficult situation for the converted starter, pitching in a sudden-death situation the entire time, and allowing a leadoff walk in the 10th and a one-out double in the 11th., but it didn't necessarily bother him.
"I honestly wasn't thinking about that," Hammel said. "I was too excited to be in there. I'd almost forgotten what to do."
Longoria's homer was the reason they were in the position. Carlos Pena opened the 13th with a single off ex-Ray Chad Gaudin, and Longoria, who had two other hits and made a heads-up defensive play, followed with a crushing blast of a 2-and-1 fastball.
"I knew I had gotten it," Longoria said. "The ball was carrying pretty good here. … I hit it on a good part of the barrel and I knew it was gone."
Of course, he wasn't trying to.
"I was just thinking base hit," Longoria said. "Really what I was thinking was to stay out of the double play."
Even then, it wasn't easy. Troy Percival got two quick outs, but had to work hard for his 12th save. He walked Emil Brown with two outs, and then watched, as all the Rays did, as Daric Barton took a huge swing and drove a wall toward right that eluded Jonny Gomes and hit off the wall for a run-scoring triple.
"It looked like it was catchable," Maddon said. "I couldn't tell how high it hit up on the wall."
But Percival didn't let Barton get any further, getting Kurt Suzuki on a foul pop to end the 3-hour, 57-minute affair.
The game went back and forth and was tied 5-5 after eight innings. The A's took an early 3-0 lead, the Rays went ahead 4-3, the A's tied it at 4, the Rays went ahead again 5-4 and were four outs from victory, when the A's rallied to tie again in the eighth.
A big reason was the Big Hurt, as Frank Thomas hit two home runs — after going 30 games without one —and delivered a key single in Oakland's eighth-inning rally that started when Shields hit Jack Cust with two outs.
The Rays were quickly down 3-0 after Shields, who's allowed only two homers in his first nine starts, covering 59 innings and 241 batters, allowed two in a three-batter span.
Thomas hit a two-run shot with two outs in the first, and Brown led off the third with another.
Thomas had gone 102 at-bats without a homer, the second-longest drought of his illustrious career. Then he hit another five innings later, a two-out drive to left, making it his 33rd career multi-homer game.
As they tend to do, the Rays came back. And just about everybody in the lineup had a hand in it.
Dioner Navarro, the top-hitting catcher in the majors at .368 going into the game, bunted for a hit in the fifth, and Eric Hinske followed with a homer, his eighth, that hit the top of the rightfield fence and bounced over.
They went ahead with two more in the sixth, when Longoria, slowly shaking his slump, doubled in one, and Cliff Floyd brought home another with a ground out.
The A's tied it on Thomas' second homer, but the Rays went ahead in the seventh, when red-hot Akinori Iwamura doubled in Jason Bartlett.
Longoria is a 22-year-old rookie, but he made a heads-up play that many veterans wouldn't think of to quash an A's rally in the third. As he stood and watched Gregorio Petit's sacrifice bunt roll slowly up the third base line, Longoria noticed that the runner who advanced to second, Kurt Suzuki, had made a wide turn, and picked up the ball and picked him off.
Marc Topkin can be reached at firstname.lastname@example.org