After putting Aaron Judge on the disabled list with a tense left oblique that will keep the right fielder staring out indefinitely, the Yankees' bullpen threw a five-run lead in the eighth inning on Sunday.
But Austin Romine helped them avoid a complete disaster when he won it in the bottom of the tenth with a single from Ian Kennedy to give them a 7-6 victory in The Bronx.
Mike Tauchman opened the entrance with a walk before Gio Urshela did the same, both outside Jake Diekman.
Thairo Estrada, who batted first-hand in his major league debut, joined the runners to bring Romine, who sent a deep ball into the center over Billy Hamilton's head to win it.
The dramatic victory caused the Yankees to return above .500, improving to 11-10.
Romine's heroic acts rescued an implosion of the Yankees' bullpen, which almost ruined the game, allowing six runs in the eighth inning.
Backed by more than six scoreless innings by James Paxton and a three-run homer in the fifth inning by Clint Frazier, the Yankees took a 5-0 lead over the eighth.
But Chad Green and Adam Ottavino left the lead astonishingly, with Ottavino allowing homers followed by Alex Gordon and Hunter Dozier to put the Royals up, 6-5.
The rally started against Green, who has been bad all year. Martin Maldonado opened with a hit to the right bottom and Green walked to Billy Hamilton before Whit Merrifield connected a single to the right to load the bases.
Ottavino then replaced Green and immediately handed a double of two runs to Adalberto Mondesi to make it 5-2. Gordon then took Ottavino deep to the right to tie the game and Dozier crushed one to the center of the right to give the Royals their first lead in an eighth six-run race.
The Yankees returned to the game at the bottom of the inning when Tauchman left with a double to the left. Urshela failed at first, with Tauchman unable to advance and Mike Ford did the same, although Tauchman moved to third with two out.
Romine's single with two outs tied to the left tied the game 6-6 before Gleyber Torres, who batted Tyler Wade, struck out the strikeouts.
Aroldis Chapman, pitching for the first time since Wednesday, arrived to start the ninth and allowed a single for Hamilton, who then stole the second. Chapman struck out Merrifield, but with Mondesi on the plate, Hamilton was third.
Chapman got Mondesi to swing in a 100 mph fastball for the second out before Gordon flew to the left in a 3-2 pitch.
Zack Britton threw the tenth and, after Dozier opened with an emerging runner, Terrance Gore was caught in a recap after a kickoff by Britton. The left-hander applied the tag in the game and appeared to hurt himself, but remained in the game and struck out the next two batters.