Detroit Tigers designated hitter Victor Martinez watches the path of his grand slam during the third inning of a baseball game against the Kansas City Royals, Sunday, Sept. 25, 2016, in Detroit.

DETROIT (AP) — Salvador Perez homered to cap a cycle by Kansas City’s first four batters of the game, and the Royals went deep three more times to beat Detroit 12-9 Sunday and drop the Tigers in the AL wild-card race.

The defending World Series champions avoided elimination from this year’s postseason race by chasing Detroit starter Matt Boyd (6-5) before he retired a hitter. Kansas City started the game with a single, a triple and a double before Perez’s two-run homer made it 4-0.

The Tigers fell 1½ games behind Baltimore for the second wild-card spot. The loss cut Cleveland’s magic number to clinch the AL Central to one — the Indians start a four-game series in Detroit on Monday night.

The Royals led 7-0 after Cheslor Cuthbert and Raul Mondesi hit consecutive homers in the third.

Dillon Gee (8-9) got the win in relief, and Wade Davis pitched the ninth for his 26th save in 29 chances. Miguel Cabrera came up as the tying run but lined out to shallow left field to end it.

Plate umpire Dan Iassogna ejected somebody from the Detroit dugout during that final at-bat. It was not immediately clear whom.

Victor Martinez hit a grand slam for Detroit in the third to make it 7-4, and the Tigers loaded the bases again that inning, chasing starter Edinson Volquez in the process. But Andrew Romine’s bunt attempt with two outs was fielded easily by reliever Peter Moylan, and the force at home ended the inning.

Detroit tried several former starters in long relief — Anibal Sanchez, Shane Greene and Mike Pelfrey all pitched — in an attempt to keep the game close, but the Royals kept adding runs. Alex Gordon’s two-run homer in the sixth made it 11-5.

Kansas City let the Tigers creep back into it by the end. Justin Upton hit a solo homer in the seventh, and Detroit also scored two runs on wild pitches, the second of which made it 11-9 in the eighth.

The Royals held on, though, and there’s still a mathematical chance they can catch the Orioles.

Cameron Maybin had four hits for the Tigers.

TRAINER’S ROOM

Tigers: RHP Jordan Zimmermann, who has been dropped from the rotation as he struggles to come back from neck problems, pitched for the first time since Sept. 10. He pitched the last three innings in relief, allowing one run and four hits.

UP NEXT

Royals: After an off day Monday, Kansas City starts RHP Ian Kennedy (11-10) against Minnesota RHP Jose Berrios (2-7) on Tuesday night.