The Union (10-4-5) twice rallied from one-goal deficits, with Maxililiano Moralez scoring on penalty kicks after Castellanos was fouled inside the box. The penalties tied it at 1 in the 23rd minute and at 2 in the 55th and gave Moralez five goals.
The momentum changed after the second penalty drew the ire of the Union. NYCFC put the pressure on and eventually Castellanos capped a nice buildup by taking a pass from Moralez and from just outside the box sent a hard roller into the corner for his fourth goal. Just seven minutes later, in the 78th minute, Castellanos and Moralez pulled off a give-and-go, with Castellanos beating the keeper to the ball. The two assists gave Moralez a league-leading 11 helpers.
First-place Philadelphia (9-5-5) took the lead in the seventh minute when Fabrice-Jean Picault settled a chip from Jamiro Monteiro and made a quick turn and strike for his second goal. Kacper Przbylko had the other Union goal in the 30th minute.
NYCFC is unbeaten at home this season and unbeaten in its last 11 league games, the longest streak in club history. It is the first win this season when conceding the first goal and first when trailing at halftime.