BOSTON -- The ball struck David Price in the chest and bounced in the air, a line drive that had a chance to devastate the Tampa Bay Rays' playoff chances.

But Evan Longoria fielded the carom and threw to first for the out, Price stayed in the game and Tampa Bay beat the Red Sox 8-5 on Sunday to take three out of four from Boston and close within two games in the AL wild-card race.

The Red Sox have lost 11 of their last 14 and are now left rooting for the New York Yankees, who play the Rays seven times in Tampa Bay's last 10 games.

"To be able to do this against this team here, if that can't bolster your confidence nothing really can," Rays manager Joe Maddon said. "Now it becomes more viable. You can see the light at the end of the tunnel, and now it's not attached to an oncoming train."

Tampa Bay already led 3-0 against a wild Tim Wakefield when Mike Aviles hit a hard shot up the middle and off the "Rays" logo below Price's right shoulder. The ball bounced toward third base for a 1-5-3 putout, and trainers went to the mound to look at Price.

After several minutes of examination -- at one point Price sat on the ground and untucked his shirt so the medical staff could look at the bruise -- Price retired Adrian Gonzalez an inning-ending groundout. Price gave up Darnell McDonald's two-run double in the fourth that made it 4-2.

Jake McGee (3-1) relieved and pitched 2 2/3 innings of relief for the win, and Joel Peralta pitched the ninth for his fifth save.

Price went to Massachusetts General Hospital for tests, which were negative, and team spokesman Rick Vaughn said he would join the team at the station for the train ride to New York.

"It was a scary moment," Maddon said. "I'm certain they did everything, and he checked out well. Knowing him, he's going to be ready for his next start."

The Rays will need him.

Tampa Bay, which trailed Boston by nine games on Sept. 3, closed within two games of the wild-card lead for the first time since June. The Red Sox have 10 games left: seven against last-place Baltimore and three at Yankee Stadium; in addition to their seven against the AL East-leading Yankees, the Rays have three against Toronto.

"The Yankees have been playing good against everybody," Red Sox designated hitter David Ortiz said. "We'll see what happens."

Second baseman Dustin Pedroia noted that the Red Sox still had the lead.

"We're winning. We've got to go out and play better. That's basically it," he said. "I'm real confident. We've got a great team and we've got to find a way to figure it out. We've got a two-game lead with 10 games to go. We're not going to sit back and feel sorry for ourselves. We've got to win. I've already turned the page."

Matt Joyce had three hits and three RBIs and the Rays capitalized on Wakefield's knuckleball to beat Boston for the eighth time in nine games. Wakefield (7-7) threw one wild pitch and catcher Jarrod Saltalamacchia muffed four of his knucklers for passed balls, miscues that contributed to three runs.

Entering with a 6-2 lead, McGee retired his first eight batters before Marco Scutaro's single chased him with two outs in the seventh. Jacoby Ellsbury singled, Aviles hit a three-run homer before Cesar Ramos struck out Gonzalez.

By then, it was too late.

The Rays didn't have much trouble with Wakefield's knuckler, but Saltalamacchia did.

Tampa Bay went ahead 3-0 in the second after Casey Kotchman led off by reaching on a passed ball on a third strike. He took second on another passed ball and scored on Johnny Damon's double.

In the fourth, Joyce doubled, took third on a passed ball and scored on Sean Rodriguez's sacrifice fly. And the Rays got another knuckler-aided run in the fifth when Desmond Jennings singled, stole second, took third on a wild pitch and scored on a passed ball.

Wakefield allowed six runs -- two earned -- six hits, one walk, one wild pitch and a hit batter in five innings. The 45-year-old earned victory No. 200 in his previous outing, his only win in his last 10 starts.

Andrew Miller added a wild pitch in the seventh that helped another run score. Aviles also had two throwing errors at third base, contributing to one more run.

Game notes

Wakefield pitched his 3,000th inning as a member of the Red Sox -- the first player in franchise history to reach the milestone. Only the Cincinnati franchise had been around as long as Boston without having one pitcher throw 3,000 innings. ... The Rays finished 7-2 in Fenway Park and 12-6 against Boston this season. ... Maddon had his team wearing high school-style letter sweaters for the train ride to New York to face the Yankees. Wade Davis (10-9) will face Ivan Nova (15-4) in the opener on Tuesday. The Red Sox have a day-night doubleheader against the Baltimore Orioles on Monday, with Kyle Weiland (0-2) starting the opener for Boston and John Lackey (12-12) pitching the night game. ... Price is the only Rays starter without a complete game. ... Red Sox INF Kevin Youkilis missed his third straight game because of a sports hernia. "He needs some time down, whether it's days or weeks, we don't know," Red Sox manager Terry Francona said.