KANSAS CITY, Mo. — With two runners aboard in the sixth inning, the Royals’ Alcides Escobar was just trying to put the pitch from Yankees reliever Blake Parker in play Monday night.

He wound up slapping it right over the wall.

The three-run homer broke open a nip-and-tuck game, and backed by a strong pitching performance by Dillon Gee, Kansas City went on to beat New York 8-5 to open their three-game series.

“I knew I hit it good,” Escobar said, “but I wasn’t 100 percent sure it was gone.”

Everybody else was sure, the way things have been going for Kansas City lately.

The reigning World Series champions won for the 18th time in 22 games, closing within two games of the second AL wild card. The Royals (69-62) were seven games below .500 as recently as Aug. 6, nearly left for dead 11 games behind the Cleveland Indians in the AL Central.

Gee (6-7) allowed four hits and a run over six sharp innings.

“The results just weren’t coming but I’ve been throwing the ball well,” said the Royals’ fifth starter, “but tonight I got an early lead and just tried to stick to it.”

Lorenzo Cain, Kendrys Morales and Alex Gordon drove in runs off Michael Pineda (6-11) during a five-hit salvo in the first inning. Pineda then retired 15 straight before getting into a two-on, no-outs jam in the seventh that led to Escobar’s homer.

“It really broke the game open for us,” Royals manager Ned Yost said.

Starlin Castro drove in two runs for the Yankees, the second in a four-run eighth inning that forced Yost to summon fill-in closer Kelvin Herrera to make a four-out save.

He retired Mark Teixeira to get out of his initial jam, then put runners on the corners in the ninth. Herrera calmly struck out Castro for his 11th save.

It was a frustrating night for the Yankees, who had elbowed their own way back in the playoff chase. They were a half-game behind Kansas City at the start of the night, but their second straight loss on the heels of a four-game winning streak was costly against a fellow contender.

Yankees manager Joe Girardi’s frustration was evident when he was tossed by plate umpire Brian O’Nora for arguing balls and strikes with the bases loaded and no outs in the eighth inning.

Didi Gregorius proceeded to deliver a two-run double, and the Yankees tacked on two more runs against the Kansas City bullpen before Herrera put a stop to their rally.

“Two different strike zones. It’s unfortunate,” Girardi said of his ejection. “Even the broadcasters were talking about it in the eighth and ninth inning. I don’t know why. I’m frustrated by it. I don’t know if you give the catchers credit. I know the last inning and the inning before that I’m watching on TV and I see it. Oh-1 is a lot different than 1-and-oh a lot of times.”

STATS AND STREAKS

The Royals have cut 7 1/2 games from their wild-card deficit in 22 games. … All nine players in the Royals starting lineup had a hit. … Pineda lost for the first time since July 31 at Tampa Bay, snapping a four-start winning streak. … Yankees CF Jacoby Ellsbury reached base on catcher’s interference for the 11th time this season, extending his major league record.

AWARD WINNERS

Yankees C Gary Sanchez won his second straight AL player of the week award. He hit .522 with three doubles, five homers and nine RBIs while walking five times in six games. … Royals 1B Eric Hosmer and Yankees SS Gregorius were chosen from their teams for the Heart and Hustle Award from the Major League Baseball Players Association.

ROYALS TRADE

The Royals acquired INF/OF Daniel Nava from the Angels for a player to be named or cash considerations. He is not on the Angels’ 40-man roster and will be assigned to Triple-A Omaha.

TRAINER’S ROOM

Royals RHP Luke Hochevar said he experienced “instant relief” after surgery for symptoms of thoracic outlet syndrome. The reliever will begin rehab with hopes of being ready for spring. “The swelling, the coldness is gone,” he said. “I haven’t had any of that happen since surgery.”

UP NEXT

Yankees RHP Masahiro Tanaka has tossed 14 2/3 scoreless innings over his last two starts. He takes on Royals RHP Edinson Volquez, who has won his last two decisions.