NEW YORK — Pinch-hitter Neil Walker connected for a solo home run in the bottom of the ninth inning, and the New York Yankees rallied from a four-run deficit to defeat the Chicago White Sox 5-4 on Tuesday night.

Aaron Hicks hit a tying homer in the eighth and rookie Miguel Andujar also had a two-run shot to help the injury-depleted Yankees win for the ninth time in 11 games and stay 61/2 games behind first-place Boston in the AL East.

Walker batted for Ronald Torreyes with one out and launched the first pitch he saw from Dylan Covey (4-12) way over the right-center wall for his ninth home run of the season. As he neared home plate, Walker tossed his helmet high in the air and was swarmed by teammates.

With the Yankees down by two, Giancarlo Stanton singled leading off the eighth to snap an 0-for-14 slump. Hicks drove a full-count pitch from Juan Minaya to right and shouted excitedly in the direction of the Yankees’ dugout as he trotted toward first.

Dellin Betances (4-3) struck out two in a perfect ninth.

New York was blanked on one hit by James Shields over the first five innings. Brett Gardner began the comeback with a leadoff triple in the sixth, and Andujar connected for his 22nd homer two outs later.

After a single and a walk ended Shields’ night, Jace Fry retired slumping Greg Bird on a liner to deep right.

ROYALS 6, TIGERS 2: Jakob Junis held scuffling Detroit to six hits in his first career complete game, Adalberto Mondesi homered to spur a five-run frame and host Kansas City beat the Tigers to begin their midweek, two-game series.

The only runs Junis (7-12) allowed came in the third, when Jeimer Candelario managed a sacrifice fly, and the eighth, when JaCoby Jones went deep. Otherwise, the Royals’ young right-hander was brisk and efficient, striking out seven without a walk to win for only the second time since May 18.

INDIANS 8, TWINS 1: Carlos Carrasco struck out 11 and withstood another scary Minnesota line drive, pitching Cleveland to a win at home. Francisco Lindor matched a career high with four hits while Jose Ramirez drove in three runs for the AL Central leaders.

Carrasco (16-7) allowed four hits in 72/3 innings. He is tied for second in the majors in wins, one behind Luis Severino of the Yankees.

In the fifth, Carrasco was hit in the glove by Ehire Adrianza’s liner. The force of the blow knocked Carrasco to the ground, but the right-hander immediately got to his feet. The ball rolled toward second baseman Jason Kipnis, who had no play at first.

ORIOLES 12, BLUE JAYS 5: Josh Rogers won his major league debut, Tim Beckham hit a three-run homer and Baltimore rolled past the visiting Blue Jays.

Rogers, acquired from the Yankees for closer Zach Britton in July, allowed three runs and seven hits with two strikeouts and a walk in five innings. He was the first left-handed pitcher to start a game for Baltimore this season.

Craig Gentry went 3 for 5 with his first home run and three RBI for the Orioles.

INTERLEAGUE

BRAVES 9, RAYS 5: Pinch-runner Adam Duvall scored the tiebreaking run on a delayed dash from third base in Atlanta’s four-run eighth inning, and the Braves beat Tampa Bay in Atlanta to snap the Rays’ eight-game winning streak.

Chaz Roe (1-3) walked Kurt Suzuki to open the eighth. Suzuki advanced to third on Ozzie Albies’ third hit, a double to the right-field corner.

NATIONAL LEAGUE

NATIONALS 5, PHILLIES 4: Pinch-running pitcher Vince Velasquez was called out for leaving second base early while tagging up, resulting in a game-ending double play that gave Washington a win in Philadelphia.

After Aaron Nola outpitched Max Scherzer for the second time in six days in a matchup of NL Cy Young Award contenders, the Phillies watched Washington rally for three runs in the ninth to take a 5-3 lead.

REDS 9, BREWERS 7: Jose Peraza started Junior Guerra’s rough outing with a two-run homer, and host Cincinnati withstood Christian Yelich’s first multihomer game for a win, extending Milwaukee’s fade in August.