Red Sox batter Ellsbury watches the ball as he follows through on his swing after he hit a three-run home run against the Yankees in the 14th inning of the second MLB American League baseball game in New York
An epic collapse by the Red Sox helped the Rays make the playoffs. Reuters

The Boston Red Sox kept their noses in front in the American League wild card race after Jacoby Ellsbury's three-run homer in the 14th inning gave them a 7-4 win over the New York Yankees in the second game of a double header on Sunday.

The win snapped a four-game losing streak, which included a 6-2 loss in opener of the double bill, and allowed the Red Sox to remain one game ahead of the charging Tampa Bay Rays in the AL wild card race with three games remaining.

Tampa Bay hit four home runs, including an inside-the-park drive by Ben Zobrist, to beat the Toronto Blue Jays 5-2 and keep the heat on Boston.

Any time you're in a run for the wild card, and you allow your team to get a win, it can't really get too much bigger, Ellsbury said. We've got to win these games to get in the playoffs. I view it as these are playoff games for us.

After losing the first game in New York, the Red Sox looked set for another defeat when starter John Lackey gave up three runs in the first inning.

However, he settled and gradually found form to match Yankees starter Ivan Nova into the seventh inning when both exited the game having allowed four runs each.

Five Red Sox relievers combined to pitch eight scoreless innings, allowing just one hit, with Franklin Morales picking up the win and Felix Doubront earning the save.

Franklin was phenomenal, said Red Sox reliever Jonathan Papelbon, who pitched 2-1/3 innings. Everybody contributed tonight, from top to bottom. Now we've got to go ball in Baltimore. That's what we've got to do.

Yankees reliever Scott Proctor gave up the home run to Ellsbury and took the loss.

In the National League wild card chase the St. Louis Cardinals continued to track down the Atlanta Braves, closing the gap to one game.

Atlanta lost 3-0 to the Washington Nationals while the Cardinals rallied to defeat the Chicago Cubs 3-2.

Yadier Molina hit a solo home run in the seventh inning to draw the Cardinals level with the Cubs and Rafael Furcal delivered the victory with a solo home run in the eighth.