KANSAS CITY, Mo. — For Pete’s sake, he crushed it.

Pete Alonso took a giant cut in Sunday’s ninth inning and unleashed a towering drive toward the left-field corner at Kauffman Stadium that landed in the record book.

With homer No. 40, the Mets first baseman set a National League rookie record and put the icing on an 11-5 victory over the Royals that gave his team a series win.

Alonso broke the NL rookie record for homers set by Cody Bellinger in 2017. He is now one short of the franchise record for homers in a season, shared by Carlos Beltran and Todd Hundley.

“It’s something that, coming into camp I didn’t know if I was going to make the team or not,” Alonso said. “To break this record and have a good season and keep playing the way I have been playing and just try to help this team win, this season has been unbelievable. It has been a dream come true so far.”

Alonso placed the record ball in his locker, next to the one he crushed in Atlanta on Thursday to tie Bellinger’s NL rookie mark. This latest souvenir was given to him by a family of Royals fans who had retrieved it. Alonso, in gratitude, gave them a signed bat, cleats and autographed baseballs.

“I’m just really thankful that they did that,” Alonso said of the fans. “That was a real classy move, for sure.”

Aaron Judge holds the MLB rookie record with 52 homers in 2017. But any next celebration for Alonso will revolve around the franchise record of 41 homers in a season.

“It says you can’t count anybody out,” manager Mickey Callaway said “Especially a guy who does everything right and works hard. If you said [he would set home run records] three years ago or even when you saw him two years ago in spring training, people would have looked at you like you had two heads. That is a lot of hard work and dedication and you have to be so proud for a kid like that.”

The Mets (64-60) survived the road trip 3-3 and will now get the comforts of Citi Field for nine games, with the Indians, Braves and Cubs headed into town. The Cubs have a two-game lead on the Mets, who are tied with the Brewers and Phillies, for the NL’s second wild-card berth.

A six-run seventh inning against the brutal Royals bullpen was the difference for the Mets. After J.D. Davis delivered a pinch-hit RBI single to tie it 4-4, Amed Rosario brought in two runs with a grounder through the drawn-in infield. Alonso smashed an RBI double as part of the onslaught in the inning.

“We know what time of the season it is,” Alonso said. “It’s time to go, so we just need to keep trying to play quality baseball and win games. Not every game is do-or-die at this point, but every game matters a lot.”

Michael Conforto entered 3-for-19 (.158) on the road trip, but launched a 452-foot rocket for a three-run homer against Glenn Sparkman in the first inning. Conforto finished with four RBIs on a day the Mets totaled 16 hits as the first four hitters combined for 11 — with Rosario, Joe Panik and Alonso recording three each and Conforto adding two more.

Zack Wheeler lasted only five innings and allowed four runs, three of which were earned, on four hits and one walk in two strikeouts. It was a second straight disappointing start for Wheeler, who pitched only five innings against the Braves last Tuesday and surrendered five earned runs.

Wheeler’s throwing error was the big play in the fifth, when the Royals scored three runs and took a 4-3 lead. After Bubba Starling and Brett Phillips singled in succession to begin the inning, Nick Dini bunted and Wheeler’s throw pulled Panik off first base. Whit Merrifield followed with an RBI single and Nicky Lopez’s fielder’s choice tied it 3-3. Hunter Dozier hit a sacrifice fly to put the Mets behind.

The Royals scratched for a run in the fourth after Dozier doubled and took third on a wild pitch. Jorge Soler reached on a catcher’s interference and the run scored on Ryan O’Hearn’s ground out.

Now the Mets are ready to come home.

“Hopefully we can continue to get that energy from the fans,” Conforto said. “We really fed off of the fans on our past homestand and it allowed us to be energized and it’s a huge advantage for us.”