KANSAS CITY, Mo. — Pete Alonso hit his 40th home run, breaking the National League rookie record, capping a late outburst by the Mets in their 11-5 victory over the Kansas City Royals on Sunday.

Michael Conforto hit a long homer in the first inning and drove in four runs. Amed Rosario put the Mets ahead by 6-4 with a two-run single in the seventh, and Alonso went deep in the ninth on an 0-2 pitch. He snapped a tie with Cody Bellinger, who launched 39 long balls for the Dodgers in 2017 on the way to winning Rookie of the Year honors.

Back in the thick of a crowded N.L. wild-card race thanks to a second-half surge, the Mets completed a 3-3 road trip and improved to 24-10 since the All-Star break.

Alonso also had an R.B.I. double and scored three times during his second consecutive three-hit game. Rosario had three hits and three R.B.I. out of the leadoff spot, and Joe Panik added three hits as the top four batters in the Mets’ lineup combined to go 11 for 18 with nine R.B.I. and seven runs.