Detroit's Max Scherzer struck out 12 in seven innings, but he was denied his 20th victory when Kansas City tied it off Drew Smyly (6-0) in the eighth. Avila answered in the bottom half with a homer to right-centre.
Joaquin Benoit pitched the ninth for his 20th save in 20 chances for the AL Central-leading Tigers.
Jeremy Guthrie (14-11) pitched all eight innings for the Royals, who began the day 3 1-2 games back in the AL wild-card race.
Avila's first homer was a two-run shot in the second. Alex Gordon hit a solo homer for Kansas City in the fourth.Suggest a correction