NEW YORK -- Keeping Lorenzo Cain in the ballpark proved difficult for the New York Yankees.
On Tuesday, the Yankees had enough offense to overcome those swings.
Despite giving up three home runs to Cain, the Yankees scored three times in the bottom of the eighth inning as Brett Gardner delivered the tiebreaking one-out double in a 10-7 victory over the Kansas City Royals.
Cain homered in three straight at-bats, joining Detroit's J.D. Martinez as the only visiting player to homer three times at the current Yankee Stadium. He also became the eighth visiting player to ever homer three times in New York and joined Bo Jackson (1990) as the second Royal to do at any version of Yankee Stadium.
"He's a really good player," Yankees manager Joe Girardi said. "We left some breaking balls up to him and he hit them hard."
Cain hit his first two home runs off Masahiro Tanaka, getting a solo shot in the third and a three-run drive in the fifth. The second home run gave the Royals a 6-5 lead until the seventh inning when the Yankees scored twice off Joakim Soria.
"That would be nice, but you just go out there play hard and see what happens," Cain said. "I had a good night but at the end of the day we lost."
Getting an RBI single by Dustin Ackley and a run-scoring double by Aaron Hicks allowed the Yankees to use two-thirds of their late-inning relief with Andrew Miller and Aroldis Chapman. Four pitches into the eighth, Cain connected off Miller and sent a 2-1 breaking ball over the right-center field fence.
"He was locked in and I made a mistake and paid for it," Miller said.
Miller stranded a runner in scoring position by striking out Omar Infante. Miller became the winning pitcher when the Yankees' Ben Gamel reached on a fielding error by shortstop Alcides Escobar and scored on Gardner's double to center off Kelvin Herrera (0-1). The Yankees took a 10-7 lead on McCann's two-run double off the center-field wall added insurance.
Those hits gave the Yankees double-digit runs for the second time this season and Aroldis Chapman preserved the lead by retiring Cain on the eighth pitch for his first save with the Yankees.
"Guys had some good at-bats and huge moments," McCann said. "We really haven't done that all year."
"We were struggling scoring runs eight, nine days ago," Girardi said. "All of a sudden our bats have started to come alive a little bit. It very well could have been a game we wouldn't have won."
Cain became the seventh player to hit three home runs in a game for the Royals. He had the ninth three-homer game in team history and the first since Kendrys Morales Sept. 20, 2015, but it was not enough as Kansas City (15-17) lost for the 11th time in 14 games.
"You keep plugging away, you know it'll break here sooner or later, hopefully sooner than later," Royals manager Ned Yost said. "When we lose, we lose as a team, we don't point fingers at the starting pitchers, we don't point fingers as the offense, we do it as a team, sooner or later it's going to break for us and when it does we'll get on a nice little run."
Dustin Ackley drove in New York's first run with a sacrifice fly in the first and Chase Headley added an RBI single in the second. Headley's hit came after Cheslor Cuthbert hit a two-run home run off Tanaka and the Yankees took a 5-3 lead into the fifth on Didi Gregorius' bases-loaded double off Brian Flynn.
While Tanaka kept his pitch count low despite allowing season highs of six runs and seven runs in seven innings, Kris Medlen became the second straight Kansas City starter to not get past the third. Medlen allowed four runs and six hits in two-plus innings.
NOTES: Kansas City RHP Chris Young will have an MRI Wednesday on his tight right forearm. He has been experiencing tightness since the end of spring training but did not say anything to the team until after Monday's start. ... New York 1B Mark Teixeira (neck spasms) missed Tuesday's game and may also miss Wednesday's contest. ... CF Jacoby Ellsbury (strained right hip) missed his fourth straight game. If he does not heal by Friday, he could be placed on the disabled list since it would be a week since the original injury. ... Royals RHP Dillon Gee will start Saturday against Atlanta in place of RHP Chris Young. ... Kansas City INF Raul Mondesi Jr. received a 50-game suspension when he tested positive for clenbuterol found in a cold medicine he took in the Dominican Republic. "It was a surprise to everyone but it just shows you, you can't take anything nowadays over the counter or anything without consulting the training staff first because things like this do happen," Kansas City manager Ned Yost said.