New York rallied from an early three-run deficit with David Wright delivering an RBI single in the fourth and Eric Young tying the contest with a two-run base hit in the fifth.
Lagares, batting just .211 to start the game, came up with a runner on second and two away in the seventh and delivered a double to deep center that turned out to be the winning score.
Jeremy Hefner (2-6) survived six innings to get the win, allowing three runs on 10 hits. Scott Rice, Carlos Torres and Bobby Parnell shut down the Phillies the rest of the way with Parnell claiming his 12th save.
The loss went to Cole Hamels (2-11), who surrendered all four runs on seven hits in six innings.