BOSTON — Sandy Leon certainly looked nifty at the right time.

The stocky Leon slid into home plate and avoided catcher Drew Butera’s tag on Eduardo Nunez’s ground out in the 10th inning Saturday night, lifting the Boston Red Sox past Kansas City 9-8 to end the Royals’ nine-game winning streak.

“I saw him reach for the ball, so the right side was wide open so I decided to go for it without him touching me,” Leon said. “It was close, but he didn’t touch me.”

Nunez also hit two solo homers over the Green Monster for the Red Sox, improving to 5 for 9 in two games since being acquired from San Francisco for two minor-league pitchers earlier in the week.

Lorenzo Cain hooked a three-run homer around the right-field pole and Whit Merrifield had a career-best four hits — all singles — for the Royals, who were looking to match their longest win streak since June 2014.

The Red Sox won for just the second time in seven games and remained one-half game behind the AL East-leading New York Yankees.

Leon opened the 10th with a double off the Green Monster against Mike Minor (5-3). After Mookie Betts was intentionally walked, both moved up on a wild pitch before Nunez hit a grounder that shortstop Alcides Escobar made a diving stab of and threw to first. Leon, who halted on the play, headed home on the throw to first and beat Eric Hosmer’s throw by slipping his hand around the tag.

“He made a very instinctive play and an athletic slide. I know that seems kind of odd because that’s Sandy,” Red Sox third base coach Brian Butterfield said. “But he made an athletic slide.”

After a delay to confirm the call, the Red Sox celebrated.

“I didn’t know what was going on. I was running so hard, I was mad when he dove so I didn’t know what was going on,” Nunez said. “When I see Leon going to home plate, I was like, ‘What’s going on? Why is he there?’ What’s going on?”

Royals manager Ned Yost waited and knew it was over after a replay.

“We missed the tag at the plate, but (Escobar) made a great play stopping it and wheeling and throwing to first and (Hosmer) got rid of it as quick as he could,” he said. “It was just a tough play. It was a great slide.”

Matt Barnes (6-2) pitched a scoreless inning for the win.

Boston tied it on Betts’ sacrifice fly in the eighth.

Trailing 6-4 in the sixth, Kansas City scored four runs on two hits, two walks and the two errors. Reliever Blaine Boyer also had a wild pitch and Christian Vazquez a passed ball.

Third baseman Rafael Devers booted Escobar’s grounder to open the inning and Alex Gordon walked. Both moved up on the wild pitch. Merrifield and Jorge Bonifacio had consecutive RBI singles to tie it. After Nunez threw high on an attempted force at second and a run scored, Salvador Perez’s sacrifice fly made it 8-6.

The Red Sox had moved ahead by scoring twice in the fourth and fifth. Vazquez had an RBI double and scored on Devers’ single. Nunez hit his second homer leading off the fifth, and the other scored on Mike Moustakas’ fielding error.

Cain’s homer cleared the short wall and Betts’ glove as he leaped, slipping into the first row to make it 4-2.

TRAINER’S ROOM

Royals: C Perez was in the lineup after taking a foul tip off his left thigh that sent him to the ground late in Friday’s win. He had left Tuesday’s game and sat out Wednesday with soreness on his right side.

Red Sox: 2B Dustin Pedroia was scratched because of soreness in his left knee after being in the original lineup. “There’s days where it will act up a little bit,” manager John Farrell said. Nunez, originally set to start at shortstop, was moved to second and Xander Bogaerts back in to short.

BAD KARMA

In Bogaerts’ first two times up, he came to the wrong “walk-up song.” Luke Bryan’s ‘Country Girl’ was played over the PA instead of his usual ‘Gonna Give it to Ya’ by DMX.

He was thrown out on the bases after reaching both times.

ROUGH DEBUT

Kansas City starter Trevor Cahill gave up eight hits and five runs over four innings in his Royals’ debut.

He was acquired in a six-player trade with San Diego on Monday.

“Not very good,” he said. “The offense did a good job of coming back. But it’d be nice to throw some more zeroes up there because they’re making the other pitcher work and putting some good at-bats together.”

MINOR MOVE

The Red Sox traded minor league LHP Luis Ysla to the Los Angeles Dodgers on Saturday for cash considerations. He was 1-5 with a 5.05 ERA with Double-A Portland.

UP NEXT

Royals: RHP Jason Hammel (4-8, 4.81 ERA) is set for the series finale. He’s winless in his last six starts, but beat Boston for his last victory on June 19.

Red Sox: LHP Drew Pomeranz (10-4, 3.59) looks to extend his career-best streak of winning his last four decisions.