The decision allowed the Tigers to complete a four-game sweep of the Royals and assured Detroit of keeping at least a one-game lead in the American League Central over the Chicago White Sox.
Detroit starter Doug Fister, who set an AL record by striking out nine consecutive batters, took a one-hitter and 4-0 lead into the eighth. But Kansas City scored three times in the inning to chase Fister.
The Royals added a run in the ninth when Billy Butler hit his 28th home run.
Prince Fielder led off the Detroit ninth with a double off reliever Tim Collins (5-4) and Delmon Young was intentionally walked. Fielder was out on a force at third but the Tigers, who put Kelly into run for Young, then loaded the bases on an error by Mike Moustakas. It was his third error and Kansas City's fifth of the game.
Alex Avila grounded down the first-base line but all the Royals could do was get one out and Kelly scored.
Joaquin Benoit (5-3) allowed the tying Kansas City run in the ninth but still got the win.
Detroit had early two-run rallies with two errors helping the first-inning rally and Quentin Berry delivering a two-out, two-run triple in the second. There was also an error in that inning.