NEW YORK (AP) -- Mark Teixeira and Chase Headley hit solo home runs off Koji Uehara in the ninth inning, and the New York Yankees stunned the Boston Red Sox 5-4 Thursday night to bolster their slim playoff hopes.

Jacoby Ellsbury, Mark Teixeira, Brian McCann and the rest of the of the New York Yankees wait for Chase Headley after his walk off home run at Yankee Stadium in the Bronx. (Rich Schultz, Getty Images)

New York had just one hit since the third inning before Teixeira drove a pitch into the second deck in right field for his 21st home run this season. One out later, Headley homered deep into the right-field bleachers against Uehara (6-5).

Adam Warren (3-5) pitched a scoreless ninth for the Yankees, who began the night four games out of the second AL wild-card spot and are in danger of missing consecutive postseasons for the first time since 1992 and `93.

David Ortiz homered twice and drove in three runs for the Red Sox. Brock Holt put Boston ahead 4-3 with a fifth-inning homer, then made a great sliding grab in the bottom half.

(Copyright 2014 The Associated Press. All rights reserved. This material may not be published, broadcast, rewritten or redistributed.)