With the Phillies trailing 2-0, Juan Pierre singled to lead off the seventh and Utley followed by lining a 1-0 pitch from Chris Young (2-2) just over the fence in the right-field corner, tying the contest.
Ruiz came up next and lofted a long fly to left that ended in the bleachers, putting the Phils ahead to stay.
Ty Wigginton added a two-run shot for Philadelphia, which snapped a six-game losing streak and evened its three-game series at Citi Field.
Cliff Lee (1-5) collected his first victory since Sept. 26, 2011, in his 14th start of the year, limiting the Mets to two runs on seven hits in an eight-inning effort. The left-hander struck out nine.
Young ended up yielding three runs on five hits over seven full frames.
Scott Hairston cracked a solo homer for the Mets.