DeGrom (2-0, 1.62 ERA) allowed two hits and walked none in his third start after spending the first part of the season on the injured list.
The two-time NL Cy Young Award winner opened the game by striking out Bryson Stott looking on a 101.1 mph fastball and then allowed a soft single to Rhys Hoskins. After Alec Bohm grounded into a force play, deGrom fanned J.T. Realmuto on three straight sliders.
DeGrom has struck out 28 of the 56 batters he has faced this season. That 50% strikeout percentage is the highest by any pitcher through their first three starts of a season since the mound moved to its current distance in 1893, according to ESPN Stats & Information research. DeGrom held the previous high, striking out 48.6% of batters to start last season.
With the win, deGrom improved to 9-1 in 20 career starts against the Phillies.
Pete Alonso hit an early RBI single as the NL East leaders improved to 31-9 following a loss and 10-4 in the season series with Philadelphia. Alonso leads the NL with 97 RBIs.
Diaz issued two walks in the ninth, and Philadelphia had runners on second and third when Nick Castellanos struck out swinging for the final out. It was Diaz's 27th save of the season.
Philadelphia wasted a terrific performance by Aaron Nola (8-9), who allowed four hits in eight innings. The right-hander struck out eight and walked one, but he dropped to 0-3 in four starts against New York this year.
The Phillies finished with three hits.
New York jumped in front in the first. Starling Marte singled, stole second and took third on a throwing error by Realmuto before scoring on Alonso's soft single to right.
After Alonso's hit, Luis Guillorme and Jeff McNeill had consecutive one-out singles in the second. Nola retired 17 in a row before McNeil started the eighth with a walk.
The Associated Press contributed to this story.