NEW YORK (AP) — Chase Headley remembered watching the New York Yankees as a kid and then as a competitor.
"You expected the magic moment, the big hit, the guy to get out of the jam," he said. "You just kind of learn to expect it."
On Thursday night, he combined with Mark Teixeira to deliver one of those indelible instants, one that gave the Yankees a little more belief that they can put together a spurt and return to the playoffs after a one-year absence.
Teixeira hit a tying home run off Koji Uehara leading off the ninth inning and Headley homered with one out, lifting New York to stunning 5-4 victory over the Boston Red Sox.
"Two home runs in the ninth — it used to happen a lot more," Teixeira said. "It's a huge win. You feel like you kind of stole one."
David Ortiz homered twice off Chris Capuano as the Red Sox built a 3-0 lead in the first three innings. After Derek Jeter hit a two-run double and scored on Carlos Beltran's single in the bottom of the third, Brock Holt put Boston ahead 4-3 with a fifth-inning homer.
Rich Hill, Esmil Rogers, Josh Outman, Shawn Kelley and Adam Warren (3-5) combined for 4 2-3 innings of one-hit relief, keeping the Yankees within one run.
New York had just one hit since the third before Teixeira fouled off a 2-2 pitch, then drove a hanging splitter into the second deck in right field for his 21st home run this season, his first since Aug. 17.
"I've been pretty bad the last few weeks," said Teixeira, who started the game in a 6-for-44 (.136) slide.
After Brian McCann flied out, Headley worked the count to 3-2 and sent another splitter from Uehara (6-5) deep into the right-field bleachers. Headley threw his helmet as he approached home plate, where he was met by his leaping teammates and doused with an orange bucket of Gatorade by Brett Gardner as he crossed.
It was Headley's second-game winning hit since the Yankees acquired him from San Diego on July 22. On the night he arrived, his 14th-inning single gave New York a 2-1 victory over Texas.
"A little bit different," Headley said, smiling. "I actually knew everybody's name this time."
New York, which remained four games out of the second AL wild-card spot with 24 games left, is in danger of missing consecutive postseasons for the first time since 1992 and '93.
"It's a great win, and we needed it," manager Joe Girardi said. "And we're going to need a lot more."
Capuano, who made 28 relief appearances with Boston this year before he was released, allowed four runs and six hits in 4 1-3 innings for the Yankees. He gave up three homers to left-handed hitters for the first time in his 239 big league pitching appearances, according to STATS.
Another midseason addition, he watched from the dugout as the ninth inning unfolded.
"I was standing on the top rail there," Capuano said, "just hoping for some magic."
Red Sox: 2B Dustin Pedroia missed his fifth straight game because of concussion-like symptoms but likely will play Friday against Toronto.
Yankees: INF-OF Martin Prado jogged before the game, and while Girardi said Prado could return from a left hamstring strain on Friday or Saturday, the player sounded less confident. ... The Yankees plan to have RHP Masahiro Tanaka (elbow) throw another bullpen session Saturday and say he must pitch in some sort of game setting to determine whether he can avoid surgery to repair a partial tear of his right ulnar collateral ligament.
Red Sox RHP Allen Webster (3-3) starts Friday, with RHP Drew Hutchison (9-11) going for the Blue Jays. ... RHP Michael Pineda (3-3) starts the Yankees' series opener against Kansas City RHP James Shields (12-7).
SPACE SHORTAGE: With September call-ups, the Yankees ran out of lockers and installed four additional stalls in the middle of their oval clubhouse.
There are 36 stalls in the home clubhouse at new Yankee Stadium, and in past seasons the team made some call-ups share space, two to a stall.
This week, two adjacent temporary stalls were installed on each side of the room, with Chaz Roe and Antoan Richardson blocking the views of David Robertson and Francisco Cervelli, and Bryan Mitchell and Chase Whitley in front of the space of Rogers and Capuano.
New York would have more space, but Jeter gets two lockers and there is one open next to Beltran's. Jeter's second locker had 31 shoe-sized boxes with the Nike/Jordan logo stacked up Thursday — in addition to 13 pairs of athletic shoes in his regular stall.
Playing his final season, Jeter finished with a .325 regular-season average at home against Boston, with 12 homers and 62 RBIs.
Richardson made his Yankees debut as a pinch runner in the seventh, his first big league appearance in three years, and was doubled up on Ichiro Suzuki's soft liner to center. He became New York's 56th player this season, tying the team record set last year.