BOSTON -- Don't count the Red Sox out just yet. That seemed to be their message Wednesday night as they erased a four-run deficit to take an 11-5 win over the Rays at Fenway Park with 37,756 watching.

By losing, the Rays fell to 2 1/2 games behind the American League East-leading Yankees, who defeated the Orioles 3-2 earlier in the day on Nick Swisher's two-run walk-off homer at Yankee Stadium. Meanwhile, Boston moved to within 6 1/2 games of Tampa Bay in the AL Wild Card race.

"Until math says they are [eliminated], they are not," manager Joe Maddon said about the Red Sox.

Talk about a frustrating day, even before batting practice, Tampa Bay had to stomach watching Swisher's winning hit on TV in the visiting clubhouse, a sight that evoked its fair share of groans. But once the game began, the Rays appeared as though they would pick up where they left off the previous night, when they routed the Red Sox, 14-5.

On Wednesday night, the Rays stormed to a 4-0 lead thanks to B.J. Upton, who continued his hot hitting with a three-run homer in the second inning off Boston starter Tim Wakefield. Upton is hitting .350 over his last six games, with three home runs. Five of Upton's 16 long balls this season have come against Boston, his most against any team.

Normally, handing Matt Garza such a lead is pretty close to a lock, but that wasn't the case in the season finale between the two teams as the Red Sox did not go gently into the night.

Adrian Beltre hit a two-run homer to start the Boston second, and an inning later, Marco Scutaro and David Ortiz added solo home runs to tie the score at 4.

Jason Bartlett's RBI double in the fourth scored Brad Hawpe to put the Rays ahead again at 5-4, but Victor Martinez answered with a home run leading off the fifth to tie the score.

The Red Sox chased Garza with one out in the fifth and a runner at second. Ryan Kalish roped an RBI double and then scored on Evan Longoria's throwing error to put the Red Sox up 7-5.

"The way we came out was really impressive, and you'd like to think with him pitching under those circumstances that we would have a chance to at least add on, but they came back real quickly," Maddon said. "You look at the gun, the velocity readings were normal.

"I'm just watching some of the replays, the location was not good. And he kept hitting bad spots and they kept hitting it out of the ballpark. And they wore him out."

Garza couldn't pinpoint what exactly happened, and suffice to say, he was disappointed in the outcome.

"[In the] first inning, [I] looked good, felt really good, [and] then I don't know what happened in that second inning," Garza said. "I walked Ortiz, then [threw] Beltre [a] fastball up and in, and he hits it out of the yard. After that, it felt like they were just in there whaling on everything I threw. I really didn't have an answer."

Garza took his eighth loss of the season while giving up six earned runs, which matched his earned run total from his last six starts combined; he went 3-2 with a 1.32 ERA in those six prior outings. The 4 1/3-inning outing was Garza's shortest in his last 11 starts since a three-inning stint against the Red Sox at Tropicana Field on July 5.

"I just went after them with heavy heaters like I usually do, and they just hit everything," Garza said. "They were sitting on breaking balls like they knew what was coming. You can't really knock them for that. I'm a fastball kind of guy, and they sit on my fastball.

"Some days you burn, some days you get burned. Today, I just got burned. You tip your cap and go on to the next one."

Red Sox manager Terry Francona called his team "sloppy in a number of areas" before adding: "But we kind of hit our way through it, which is not easy to do against their guy."

The Rays' bullpen allowed five runs to score Wednesday night. Martinez had an RBI single in the sixth and Scutaro added a two-run homer in the three-run seventh to put the Red Sox up 11-5. Martinez finished his season's work against the Rays with a .405 average in 11 games.

"We got off to a pretty good start, but it kind of went dead for the rest of the game, but that's baseball, that happens," Upton said. "We're done with these guys for the rest of the year."

At the end of Wednesday night, having the Red Sox in the rearview mirror was a pretty nice sight.