KANSAS CITY, Mo. — On the final night of May, three weeks before the first grand slam of Salvador Perez’s career, before the Royals edged the Boston Red Sox 6-4 on Wednesday afternoon, reserve catcher Drew Butera picked up a baseball bat near home plate at Kauffman Stadium.

It was May 31, and the Royals were concluding a three-game series against the Detroit Tigers. Butera was starting in place of Perez, the Royals’ perennial All-Star. The bat belonged to future Miguel Cabrera, the Tigers’ future Hall of Famer, and Butera immediately loved the feel.

It was too heavy for him, 32 ounces in all, but perfect to swing during batting practice. So Butera sent word to the Tigers, asking Cabrera if he had an extra bat he could spare. Cabrera sent over two, a parting gift as the Tigers left town, and three weeks later, one of those bats ended up in Perez’s locker on Wednesday morning.

“As soon as he came in the clubhouse, he just put it in my locker,” Perez said of Butera. “Just like: ‘Use it today.’ “

In truth, Butera said, Perez had loved the feel, too. It was his size, and he could use it in games. Inscribed on the barrel was the name of Cabrera, his countryman and former teammate on Team Venezuela.

“I’ve always said,” Butera said. “Some guys just have magic sticks.”

So Perez used the bat, and that is the story behind the most momentous homer of this Royals season, a grand slam in the eighth inning against Red Sox reliever Robby Scott, a 412-foot shot that tore through the humid afternoon air and landed in the first row of the Hall of Fame seats, just beyond the Royals’ bullpen in left field.

In 2,795 career at-bats, Perez had never hit a home run with the bases loaded. In moments, Perez turned a 4-2 deficit into a 6-4 lead. The go-ahead grand slam was the first by a Royals hitter in the eighth inning or later since Frank White in 1986. The Red Sox were 29-0 this season when leading entering the eighth inning.

One inning later, the Royals closed out their fourth straight series victory, winning for the ninth time in 11 games.

“I can say: ‘I got one grand slam,’ “ Perez said.

In the moments after contact, manager Ned Yost locked his eyes on the baseball and followed its flight. In the clubhouse, starting pitcher Ian Kennedy monitored the at-bat on a television.

“He tried to go inside and Salvy kept his hands in there,” Kennedy said. “That was pretty awesome.”

The swing, of course, had taken Kennedy off the hook. In the fourth, he allowed back-to-back homers to Boston’s Andrew Benintendi and Jackie Bradley Jr., which knotted the score at 2-2. In the fifth, Kennedy committed an awkward throwing error, which led to two more Red Sox runs.

As he labored in the afternoon sun, Kennedy allowed a leadoff single to Christian Vazquez in the fifth. Moments later, Boston’s Deven Marrero dropped down a sacrifice bunt attempt. Kennedy sprang from the mound and fielded the ball, unleashing an awkward throw that sailed high over first base. The moment frustrated him.

“I didn’t see anybody at first and I was already committed to throwing,” he said. “I was trying to time it. And it kind of just floated out of my hand. It almost cost us the game.”

The error — combined with another error credited to first baseman Cheslor Cuthbert on an errant pickoff throw from Mike Minor later in the inning — helped gift the Red Sox two runs. As the Royals came to bat trailing 4-2 in the eighth, Yost just had one thought: “We need somebody to get on base.”

The drama began to unfold as Red Sox reliever Matt Barnes issued walks to Jorge Bonifacio and Lorenzo Cain. Red Sox manager John Farrell inserted Scott, a left-hander, to face Eric Hosmer. Four pitches later, the bases were loaded for Perez.

It was, in some respect, a classic Perez at-bat. Scott kept throwing fastballs out of the strike zone. Perez kept hacking away.

As the day began Wednesday, only three players in baseball had swung at a higher percentage of pitches than Perez’s 56.9 percent. As Scott attacked Perez with nine straight fastballs, Perez offered at six of them, including three that were well off the plate.

“If I see it close, I’m swinging,” Perez said. “You guys know me: I like to swing.”

But finally, there was a breakthrough. The ninth and final pitch stayed up and out over the plate. Perez let loose. The ball left an imprint on the face of Cabrera’s bat. It also left Perez wondering why he didn’t see any off-speed pitches.

“Thank you for throwing fastballs,” Perez said.

In the moments after the win, Perez sauntered to a press conference room on the first floor of Kauffman Stadium and told the story of Cabrera’s bat; how it had ended up in his hands on Wednesday afternoon; how it collected three base hits and his 15th homer of the season.

“I think I’m gonna use it on Friday, too,” Perez said. “What do you guys think?”

Before he can do that, the Royals will enjoy a day off on Thursday. They will open a three-game series against the Toronto Blue Jays on Friday. They will seek to maintain their current form. They are 25-16 since May 8, just three games behind first-place Cleveland, who played the Baltimore Orioles on Wednesday night. And their quick-strike offense has become a force, rather than a liability.

On Wednesday, Perez turned a loss into joy with one swing of the bat. And yes, the bat. It had traveled from Cabrera to Butera to Perez’s hands on early Wednesday. By late Wednesday afternoon, it had a permanent home in his possession.

“I don’t want to break that one,” Perez said. “I’m gonna call Miggy and (say): ‘Hey, you gotta send me some more bats, please.’ ”