The Boston Red Sox will host the New York Yankees in the American League wild-card game Tuesday night after the rivals’ biggest stars came up big when their teams needed it most on Sunday.

Aaron Judge drove home the winning run with a one-out single in the ninth inning of the Yankees’ 1-0 win over the Tampa Bay Rays while Red Sox slugger Rafael Devers‘ two-run homer in the ninth inning broke a 5-5 tie with the Washington Nationals.

It was Devers’ second homer of the game — and 38th of the season — came on a drive to straightaway center field off Kyle Finnegan on a 2-1 pitch with one out after Kyle Schwarber reached on an error. Boston went on to win 7-5.

The homer capped a four-hit, four-RBIs afternoon for Devers, brought teammates bounding out of the dugout and prompted chants of “Yankees suck!” from some of Boston’s fans who could be heard throughout much of the afternoon in a crowd of 33,986 at Nationals Park.

Meanwhile, at Yankees Stadium, shortstop Gio Urshela made a Jeter-esque catch, charging recklessly into the visiting dugout, to help New York finish the year 92-70, punching a fifth consecutive postseason ticket after nearly falling into a labyrinth of tiebreaker scenarios.

“It’s been a crazy, wild, tough year,” manager Aaron Boone said. “Fitting that it would come down to the last day to get in, but I love our group.”

The victories by New York and Boston officially eliminated the surging Seattle Mariners and Toronto Blue Jays from the playoffs.

Rougned Odor led off the ninth with a single against Josh Fleming (10-8), just New York’s second hit. Pinch-runner Tyler Wade advanced to second on Gleyber Torres‘ flyout to the warning track in center, and Anthony Rizzo moved Wade to third with a one-out single.

Andrew Kittredge came on to face Judge, who ripped a 104.4 mph line drive off the right-hander’s glove. The ball skipped toward drawn-in second baseman Brandon Lowe, whose off-balance throw home wasn’t nearly in time to catch a sliding Wade.

Teammates swarmed a smiling Judge midway between first and second, and fans chanted “MVP! MVP!” at the face of the franchise during an on-field interview. The clutch single was Judge’s eighth go-ahead hit in the 8th inning or later this season, which is the most by a Yankees player in a season since 1961, according to ESPN’s Stats and Information research.

“I wouldn’t say we exhaled,” Judge said. “We still have a lot of work to do.”

The Red Sox, faced with several Game 163 possibilities should they have lost on Sunday, fell behind 5-1 to the Nationals thanks in part to a shaky start by ace Chris Sale, who went just 2 1/3 innings.

Devers led off the fourth with a drive off a 1-2 fastball from Joan Adon, a 23-year-old right-hander who struck out nine batters in 5 1/3 innings in his major league debut. Devers added an RBI single off Erick Fedde in the seventh that brought the visitors within 5-3, and Alex Verdugo‘s two-run double that inning tied it at 5.

Information from The Associated Press was used in this story.