"When the season is over, we want to be on top regardless of how we get there," Boston manager Terry Francona said. "A tough game tonight. Our job now is to show up tomorrow and be one run better instead of one run worse."
It is the closest the Yankees, who beat Baltimore 3-2 on Monday, have been since July 26, when they were one game behind.
"We're fine," Boston first baseman Kevin Millar said. "One thing we don't do is panic. One thing we don't do is get negative. We believe in each other ... pick each other up. That's all you can do."
David Ortiz drove in four runs, two on a double in the seventh that got Boston within 7-6 and another on his 44th homer that made it 8-7 with two outs in the ninth.
"The Yankees, they probably could play no worse than what they did early in the season," Ortiz said, referring to New York's poor start. "They're not going to play any worse than that, guaranteed. The way those guys are playing over there right now, you got to bring your 'A' game to beat them."
The Devil Rays had gone ahead 8-6 in the eighth on an RBI grounder by Jonny Gomes.
"The role we fell into is spoilers," Gomes said. "We want to be on other side of that. It's not like we're playing for nothing. A win or loss on our record can affect other teams and races."
"What can you do?" Ortiz said. "Nothing but keep fighting."
The Devil Rays chased starter David Wells in the third inning in beating the Red Sox for the fifth time in 17 meetings this season.
Francona said Wells was bothered by a sore right knee and that the left-hander might get a cortisone shot before his next scheduled start on Sunday.
"I'm not going to make any excuses," Wells said. "I just went out and stunk it up tonight."
Hendrickson (10-7) tied Victor Zambrano's franchise mark established last year with his six-game winning streak. He gave up six runs and eight hits in 6 1/3 innings.
Wells didn't resemble the pitcher who was 10-1 in 15 previous starts against Tampa Bay. The left-hander failed to cover first on a grounder in the big inning and tied a season high with two walks.
After working out of jams in the first two innings and holding a 2-0 lead, Wells recorded only two outs in the third when he allowed four runs and six hits.
Huff was credited with an RBI single in the third when Wells never got to the base to take a throw on a high hopper to first with one out. Alex Gonzalez tied it at 2 with a run-scoring double.
Wells gave up four runs and 10 hits in 2 2/3 innings. He threw 76 pitches, 37 in the third inning.
Graffanino was to be evaluated Tuesday.
Huff's RBI grounder in the fourth put Tampa Bay ahead 5-4.
Red Sox rookie Craig Hansen, the team's first-round draft pick in June, was recalled from Double-A Portland earlier in the day and struck out two during a perfect fifth in his major-league debut.
Ortiz leads the majors with 136 RBI. The 44 homers are tied with New York's Alex Rodriguez for the AL lead. ... Wells' only loss to Tampa Bay was on June 25, 1999. ... Boston right fielder Trot Nixon had flu-like symptoms and was scratched from the starting lineup. Francona said Nixon, who received an IV, was available to pinch-hit. ... The Red Sox also recalled infielder Hanley Ramirez from Portland. ... Yankees senior vice president of player personnel Gordon Blakeley, advance scouts Chuck Cottier and Wade Taylor and pro scout Joe Caro were at the game. The Yankees and Red Sox end the regular season with a three-game series in Boston.