NEW YORK -- - Down five runs in the third inning with a rookie on the mound, the New York Yankees saw their season spiraling out of control.
Aaron Judge and Gary Sánchez revived them with the type of win they had not put together in more than a year.
Judge hit a tying three-run homer with two outs in the eighth inning and Sánchez singled in the 10th to drive in Gleyber Torres on the day the infielder lost the shortstop job, lifting the Yankees over the Minnesota Twins 6-5 Monday.
"It's a roller coaster, but you got to enjoy the ride," Judge said. "It's not over yet."
DJ LeMahieu began the comeback with a sacrifice fly in the sixth that Max Kepler caught with a leap against the right-field wall. Joey Gallo added his 33rd homer, his eighth with the Yankees, in the seventh off Tyler Duffey.
Duffey walked pinch-hitter Anthony Rizzo leading off the eighth and Brett Gardner with two outs. Twins manager Rocco Baldelli was ejected for taking issue with the calls of plate umpire Jeff Nelson, and Colomé relieved.
"It's frustrating when you go out and do your job and execute a pitch," Duffey said, "and the umpire just flat-out misses it. It seems to happen a lot in this stadium for some reason. I don't know if they're afraid to punch people out in Yankee Stadium."
Judge, back in the lineup a day after leaving in the third inning against the Mets because of dizziness, sent a cutter to the opposite field in right for his 33rd homer. It was his 12th tying or go-ahead homer in the eighth or later since the start of 2017.
New York won for just the fourth time in 16 games following a 13-game winning streak and moved one percentage point ahead of Boston for the second AL wild-card berth, one game behind Toronto, with 18 games left. The Yankees had lost six straight home games for the first time in a decade.
Twice this season they had lost after leading by five runs, but they had not overcome a five-run deficit to win since Aug. 30 last year against the Mets. And they had been 0-35 when trailing by at least four runs, joining Miami and St. Louis as the only winless teams in that situation.
"It was really good to see the fight that we had today," Gallo said. "We could have easily let that game go."
Jorge Polanco and Miguel Sanó hit two-run homers in the first, with Polanco reaching 30 for the first time. Byron Buxton homered for a 5-0 lead in the third off Luis Gil, who didn't allow another run through six innings.
Andrew Heaney, Albert Abreu, Aroldis Chapman and Clay Holmes (5-1) followed with two-hit, shutout relief. Chapman retired Polanco on a flyout in front of the center-field warning track to strand two runners in the ninth.
Manager Aaron Boone said before the game that Torres will spend the rest of the season at second. Torres was the automatic runner on second under pandemic rules when Sánchez singled sharply with one out in the 10th off Ralph Garza Jr. (1-3). Torres scored standing up as the Yankees streamed out of the dugout with their 10th walk-off win, their most since 2009.
Twins starter John Gant, his fastball velocity down about 4 mph from its season average of 92 mph-plus. lasted just 12 pitches and two outs and left with a strained lower abdomen. He will go on the injured list.
Minnesota arrived for the makeup of an Aug. 22 rainout at 1:30 a.m. because of mechanical trouble on its charter. The Twins (63-81) lost for the fourth time in five games and for the first time since 2018 will not have a winning record. The two-time defending AL Central champions were mathematically eliminated from division contention.
"I'm sure there's some emotional guys in the clubhouse right now," Baldelli said.
New York clinched its 30th consecutive winning record at home at 41-31, second to its major league-record 47 years from 1918-64.
The Yankees went 6-1 against Minnesota and are 109-32 against the Twins since 2002. Minnesota has lost 21 of its last 23 in the Bronx.
Twins OF Brent Rooker was placed on the paternity list as his wife delivered a girl. Blair Evelyn Rooker was born at 4:10 a.m. CDT Monday, 7 pounds, 13 ounces and 20 inches long. ... RHP Kyle Barraclough was recalled from Triple-A St. Paul.
Yankees RHP Sal Romano refused an outright assignment and elected free agency. ... RHP Clarke Schmidt was optioned to Triple-A Scranton/Wilkes-Barre.
Yankees: RHP Jameson Tallion (ankle) threw on flat ground and could soon pitch off a mound.
Twins: RHP Joe Ryan (1-1, 2.25 ERA) starts a day-night doubleheader opener at home against Cleveland after retiring his first 19 batters and pitching seven shutout innings at the Indians last week. LHP Charlie Barnes will be recalled to start the second game.