ST. PETERSBURG, Fla. -- Tampa Bay rookie Wil Myers knew the slumping Rays badly needed a victory and he came through with a late big hit.
Myers had a tiebreaking double in the eighth inning and the Rays beat the Boston Red Sox 4-3 on Thursday night to avoid a three-game sweep.
"We needed it bad ... we needed to win bad," Myers said. "With the wild-card getting tight, we needed a win here and we didn't want to get swept by those guys."
Jake McGee (5-3) pitched a scoreless eighth before Fernando Rodney got three outs to earn his 34th save. The Rays lead the crowded race for the second AL wild card despite going 5-13 since Aug. 25. Tampa Bay remained one game ahead of the New York Yankees, who beat Baltimore 6-5 later Thursday night.
"We've got to keep winning," Myers said. "Just not one and lose tomorrow. We need to win this series coming up and keep it going the rest of the year."
The Rays open a three-game series at Minnesota on Friday night before returning home to play four games each against playoff contenders Texas and Baltimore.
"We're going to get real hot at exactly the right time," Tampa Bay manager Joe Maddon said. "A game like this really promotes that emotional lift that we needed right now."
"You try and win every series," Saltalamacchia said. "That's the No. 1 goal, and we lost tonight but we took a good two out of three. So we'll go home against New York and worry about Game 1. And see what happens after that."
Boston will play the Yankees three times this weekend at Fenway Park.
The Red Sox threatened in the ninth when Stephen Drew had an infield single and pinch-hitter Mike Carp walked with one out. Rodney worked out of the jam when pinch-hitter Will Middlebrooks lined out to third and Dustin Pedroia popped out.
Ortiz hit an opposite-field solo homer to left and Drew had a run-scoring double as the Red Sox tied it at 3 in the sixth. Ortiz has 43 career homers against Tampa Bay, the second-most by an opponent. Of those, 28 have come at Tropicana Field.
Longoria tripled and scored on Myers' single to put the Rays ahead 1-0 in the second. James Loney made it 2-0 with an RBI double in the third.
Saltalamacchia snapped an 0-for-21 stretch and pulled Boston to 2-1 on a fourth-inning homer.
Tampa Bay went up 3-1 in the bottom half when Desmond Jennings hit a solo home run.
Rays starter Jeremy Hellickson allowed three runs and four hits in 5 1/3 innings.
Boston manager John Farrell said right-hander Jake Peavy got hit on the right wrist by Jennings' drive in the sixth. The ball was redirected to third baseman Xander Bogaerts, who got a forceout at second.
Peavy gave up three runs, four hits and five walks over six innings.
"The command was a little bit missing obviously, with the number of walks issued," Farrell said. "But his competitiveness, he finds a way to make a pitch in a key moment."
Ortiz has 428 homers, which moved him past Mike Piazza for 46th place all-time. ... The Red Sox will honor Yankees closer Mariano Rivera before his last regular-season game at Fenway Park on Sunday. Rivera is retiring after the season. ... Boston OF Jacoby Ellsbury (foot), who missed his sixth consecutive game and is not yet doing baseball activities, will have his status evaluated in the next few days. ... Rays C Jose Molina left the team to be with his mother, who had surgery. He is expected back Friday. ... Shane Victorino was out of the Red Sox lineup because Farrell wanted to give the outfielder a day off from playing on the artificial turf. ... 2012 Olympic silver medalist and professional beach volleyball star Jen Kessy served a volleyball from the mound for the ceremonial first pitch.