Hamels (3-5) allowed two runs and seven hits, striking out seven and walking two for his first victory since June 6 - a span of six starts. Jonathan Papelbon pitched a perfect ninth for his 20th save in 22 chances.
Utley, the starting National League All-Star second baseman, staked the Phillies to a 2-0 lead in the first inning with his seventh homer. It was the 27th home run allowed by Marco Estrada (7-6), the most in the majors.
It was the sixth loss in seven games for the Brewers, who have had sole possession of first place in the NL Central since April 9.