The New York Yankees and Boston Red Sox each scored dramatic late-inning wins to bring the MLB regular season to a thrilling end on Sunday, setting up a wild-card showdown between the longtime rivals.

The final day of a 162-game, six-month marathon began with four teams — the Yankees, Red Sox, Toronto Blue Jays and Seattle Mariners — all in contention for two American League wild-card spots, and when the dust settled it was two of baseball's most storied clubs still standing.

The Yankees left it about as late as they possibly could to clinch their place, with Aaron Judge connecting on a walk-off single in the bottom of the ninth for a 1-0 win over the Tampa Bay Rays.