The Phillies lost their sixth in a row, leaving the would-be tying run on third base in the ninth inning.
Doug Fister held Philadelphia to three hits and a run through eight, striking out six and walking one.
Fister (9-5) was relieved in the ninth by Joaquin Benoit, who gave up a leadoff single to Jimmy Rollins. After stealing both second and third, Rollins was left on base when Darin Ruf grounded out to end the game. It was Benoit's 10th save.
Michael Young singled in Philadelphia's only run in the third, but Detroit moved in front in the fifth when Hernan Perez walked, Ramon Santiago doubled and Avila produced his two-RBI double to center.
Those runs were charged to Cole Hamels (4-13), who gave up six hits in seven innings.
Putin thinks Obama would save him if he were drowning
Justin Bieber crashes Drake Bell's album release party