The impulse struck Mike Moustakas mid-sprint. He could not deduce its origins.

“I don’t have any kind of explanation,” Moustakas said. “It just kind of happened.”

What happened was this: He dove into first base to beat out a double-play ball in the ninth inning of a 4-3 Royals victory, waited for a challenge from his dugout to overturn the call and pocketed his fourth RBI on the night. The run proved critical when closer Greg Holland surrendered a run in the bottom of the inning to the Arizona Diamondbacks.

Boosted by Moustakas’ late effort, the Royals (59-53) set themselves up for a sweep on Thursday. Moustakas walloped a two-run homer in the second, added an RBI single in the fourth and delivered his first four-RBI game since July 30, 2013.

The rest of the lineup failed to ignite a fireworks display similar to Tuesday’s 12-run flurry, but still captured their 11th victory in 14 games and their five consecutive series.

“If you can win series from here on out, we’re going to be there the whole way,” manager Ned Yost said. “And I’m not just talking about the second wild card.”

A loss by Detroit slimmed their advantage in the American League Central. The Royals climbed to 31/2 back and remained a half-game behind the Toronto Blue Jays in the wild-card hunt. They did so on a shaky evening from their starting pitcher.

Yordano Ventura (9-8, 3.47 ERA) tallied six innings of two-run baseball despite nonexistent command of his secondary offerings. He offset eight hits allowed with eight strikeouts.

In the final three innings, Kansas City unleashed its unrelenting bullpen. Kelvin Herrera threw 100-mph gas in the seventh. Wade Davis worked around a pair of singles for a scoreless eighth. The final inning belonged to Greg Holland, who added to his American League lead with 32 saves, but gave up a pair of singles followed by a sacrifice fly for Mark Trumbo.

“At the end of the game, that run turns out to be huge,” Moustakas said. “That one was probably the most important run for us.”

The Diamondbacks cracked 12 hits in all, and they were on Ventura from the outset. He allowed a leadoff double in the second. Miguel Montero scalded a fastball off the wall in left center. Ventura recovered to bully the bottom of Arizona’s order, striking out outfielder Roger Kieschnick and causing Arizona starter Josh Collmenter to fly out.