Avila provided all three Detroit runs and Prince Fielder went 3-for-4 as the Tigers took the rubber match of a three-game set.
Tigers starter Max Scherzer fell short of a 20th win for the fourth straight outing, settling for seven innings of one-run ball with a season high-tying 12 strikeouts.
Drew Smyly (6-0) instead earned the decision and Joaquin Benoit racked up his 20th save as Detroit shrank its magic number to win the American League Central to nine.
Jeremy Guthrie (14-11) was hung with the complete-game loss, allowing three runs on 13 hits.
Alex Gordon homered for the Royals, whose AL wild card playoff hopes took a hit.
Boston schools pull out free condoms over wrapping complaints
Millions of Getty images now available for free via embed tool