Gregorius led off the inning with an infield single against Chris Young (3-9) off first baseman Eric Hosmer's glove. He advanced to third on Starlin Castro's double down the left field and came home on McCann's sacrifice fly off Matt Strahm.
Ben Heller (1-0) worked a spotless 12th inning to pick up his first career victory and Dellin Betances earned his seventh save as the Yankees (69-63) moved within 2 1/2 games of the Baltimore Orioles for the second wild card spot and kept the Royals (69-64) three games out
Paulo Orlando lined out to Castro at second to end the Royals 11th with pinch runner Billy Burns, who stole two bases in the inning, and Alex Gordon in scoring position.
Young worked out of a bases loaded one-out jam in the 12th by Mark Teixeira to ground out but was not fortunate in the next inning.
The Yankees trailed 4-0 after three innings before rallying.
Castro hit a two-run home run with two out in the sixth with Gary Sanchez on base to cut the Royals' lead to 4-3. Castro parked a 93 mile per hour fastball over the left-center fence after Gregorius lifted a sacrifice fly to left field.
The Yankees forged a 4-4 tie in the seventh and chased Ian Kennedy. Scott Alexander, who was just recalled from Triple-A Omaha, replaced Kennedy after he walked Aaron Hicks with one out. Hicks took third on Brett Gardner's single to right and scored on Jacoby Ellsbury's sacrifice fly.
Kennedy allowed four runs on six hits and two walks. He had yielded only four runs in his previous August starts.
Kendrys Morales hit a two-run homer with two outs in the first. He swatted Luis Cessa's first-pitch curveball over the center-field fence, his second straight game with a homer. It was Morales' team-leading 22nd home run, matching his 2015 season total.
Hosmer hit an opposite-field homer, his 19th, to lead off the third, tucking a 1-0 Cessa offering just inside the left-field foul pole. It was Hosmer's fourth homer and 14th RBI in his past 15 games.
Kennedy held the Yankees to four singles the first five innings with only one base runner making it to second base.
NOTES: The Royals placed RHP Chien-Ming Wang on the 15-day disabled list with right biceps tendinitis and optioned INF Christian Colon to Triple-A Omaha. The Royals recalled LHP Scott Alexander and RHP Brooks Pounders from the Storm Chasers to bolster their bullpen. This is Alexander's second stint and Pounders' third with the Royals this season. Alexander was 2-0 with a 3.00 ERA in 22 appearances with Omaha and Pounders was 5-3 with a 3.14 ERA. ... 1B Mark Teixeira returned to the Yankees' lineup after not starting the previous two games because of neck issues. ... Royals OF Lorenzo Cain was not in the lineup because a tender wrist. ... The Yankees dealt OF Ben Gamel, who was the International League MVP, to the Yankees for young minor league RHPs Jio Orozco, 19, and Juan De Paula, 18. ... The Yankees also acquired OF Eric Young Jr. from the Brewers for cash considerations and assigned him to Triple-A Scranton/Wilkes-Barre, although he will be called up in September when rosters can be expanded. Young, 31, has stolen 144 bases in 179 attempts, an 80.4 percent success rate, in 557 big league games.