Mark Teixeira hit a tying homer into the second deck in rightfield off Koji Uehara with none out in the ninth inning. One out later, Chase Headley won it with a blast into the second level of the rightfield bleachers, sending 44,708 at the Stadium into hysterics. Almost before leaving the batter's box, he threw his right fist in the air.

"It's a great win, and we needed it," Joe Girardi said. "And we're going to need a lot more."

Both homers came off splitters, Uehara's best pitch. Teixeira's came on 2-and-2 and Headley's on 3-and-2. "It's been an up-and-down season for all of us," said Teixeira, who entered the game in a 2-for-23 slide and went 2-for-4. "When you can win a game like that, and win a series in that fashion, it just doesn't happen very much. You don't hit two home runs off of one of the best closers in baseball very much, so that was a fun dugout."

Headley said he's noticed a pervasive confidence in the clubhouse since he arrived July 22. Everyone believes the kind of run the Yankees have yet to put together is coming.

"We're very confident, I can tell you that much. The guys in the clubhouse believe it's going to happen," Headley said. "It hadn't happened yet, but we expect it to happen. Obviously, walk-off wins, getting that type of win, gives you some momentum. Hopefully we can build on this, but again, we expect it to happen. We're going to go on a run and get it done."

And now, the splash of cold water.

Thrilling win aside, the Yankees (72-66) remained 9½ games behind the AL East-leading Orioles and four games behind the Tigers for the second wild-card spot. They're also 31/2 games behind the Mariners. The AL Central-leading Royals are in town starting tonight, a major step up from last-place Boston (61-79).

The Red Sox, who took a 3-0 lead in the third, hit three homers off Chris Capuano -- two by David Ortiz (32 homers, 98 RBIs) and one by Brock Holt, who gave Boston a 4-3 lead in the fifth with a shot to right that just cleared the leap of Ichiro Suzuki. Capuano allowed three homers by lefthanded hitters for the first time in 239 big-league appearances, according to STATS.

Adam Warren (3-5), who stranded runners at second and third in the top of the ninth by getting Holt to ground out, picked up the victory. After Capuano left with one out in the fifth, five relievers combined to allow one hit the rest of the way. "Those guys, one after another, were sharp," Capuano said.

Boston righthander Brandon Workman nearly earned his first victory since June 10. Workman, who entered the game 1-8 with a 4.93 ERA, allowed three runs and five hits in six innings.

Entering the ninth, the Yankees had managed only an infield single after tying the score at 3-3 in the third on Derek Jeter's long two-run double to center and Carlos Beltran's two-out RBI single.

"I've talked about this guy, he's been big in the months of September and October and understands what this is about," Girardi said of Jeter. "I thought he swung the bat pretty good last night and the night before, but this is a guy we need to be productive as well."