The Royals have lost six in a row and 11 of 12. Kansas City starter Brady Singer was removed after just three innings with tightness in his pitching shoulder.
Tarik Skubal (4-7) picked up the win. He allowed three runs on six hits in six innings, striking out seven.
Michael Fulmer earned his fifth save in six chances.
Adalberto Mondesi hit a home run in his first at-bat since returning from the injured list. Salvador Perez also connected for the Royals, hitting his 17th of the season.
Greg Holland (2-2) gave up three runs while getting just one out.
Holland issued a four-pitch walk to the first batter he faced, Niko Goodrum, in the seventh and Castro homered to make it 3-all. Holland left after a one-out single by Robbie Grossman, and reliever Scott Barlow gave up a single to Akil Baddoo and threw a wild pitch that let the go-ahead run score.
The Tigers’ fifth run also scored on a wild pitch in the eighth and Detroit added a run in the ninth for a 6-3 lead.
Whit Merrifield hit an RBI double with two outs in the Royals ninth and Carlos Santana followed with a run-scoring single. Perez strut out to end the game.
Singer, who allowed one run on four hits, became the first Royals pitcher in five games not to surrender a run in the first inning when he worked around a one-out walk.
Mondesi hit a 445-foot homer in the second, giving the Royals their first lead in 46 innings.
Royals: SS Mondesi was activated from the 10-day IL on Tuesday, but he didn’t appear in the game. He was in the starting lineup Wednesday, batting fifth. Mondesi has been out since May 31 with a left hamstring strain. Royals manager Mike Matheny said the plan was to activate Mondesi for Wednesday’s game, but RHP Ronald Bolanos was placed on the IL opening a spot a day earlier. Mondesi was in the on-deck circle as a pinch-hitter when the final out was made.
Tigers: Open a four-game series against the Los Angeles Angels in Anaheim. RHP Matt Manning will make his major league debut. Manning was 1-3 with an 8.07 ERA in seven starts with Triple-A Toledo. The Tigers have not won a season series with the Angels since 2010.
Royals: After an off-day Thursday, Kansas City will continue the homestand with the first of three games against the Boston Red Sox on Friday night. RHP Jackson Kowar (0-2, 36.00 ERA) will try to find the form that made him one of the Royals’ top prospects. Kowar has not lasted more than 1 1/3 inning in either of his starts, and he’s allowed four earned runs in each.