The lone hit off Hamels was a two-out double in the second by Francisco Cervelli that tied it 1-1. The left-hander struck out two, walked one and hit a batter during his 33-pitch outing.
Yankees starter Bartolo Colon gave up one run and two hits in two innings. The right-hander threw 23 of 36 pitches for strikes.
Dane Sardinha put the Phillies ahead 5-4 in the eighth on a two-run bloop single to left. Mark Teixeria, who was hit on the top of the right toe by Hamels in the first, hit a fifth-inning RBI triple.