MLS Wrap: Red Bulls win thriller, Rapids edge Galaxy
Australia international Tim Cahill and Fabian Espindola gave the hosts a two-goal buffer inside the opening 23 minutes of the MLS clash at Red Bull Arena.
But a hat-trick from Alvaro Saborio looked to have completed a stunning comeback until Espindola converted his second penalty of the match to level proceedings.
And in another stunning twist, McCarty headed home in the 94th minute to condemn Real Salt Lake to their second consecutive defeat.
The result saw New York close to within a point of Eastern Conference pacesetters Sporting Kansas City, who were beaten 1-0 by Montreal Impact.
Meanwhile, the Colorado Rapids continued their surge up the standings with a 2-0 victory over defending champions the Los Angeles Galaxy.
Goals on either side of the break from Hendry Thomas and Dillon Powers extended Colorado's unbeaten run to six matches, while the Galaxy slumped to their third away defeat in succession.
In other results, the San Jose Earthquakes stunned the high-flying Portland Timbers 2-1 at Buck Shaw Stadium.
Two goals in three minutes from Victor Bernardez and Steven Lenhart proved enough to send the second-placed Timbers home empty handed.
Philadelphia Union became the first team to leave BC Place with maximum points this season, defeating the 10-man Vancouver Whitecaps 1-0, courtesy of Antoine Hoppenot's strike five minutes from time.
Elsewhere, Toronto FC scored twice in the final six minutes to defeat the Columbus Crew 2-1, DC United took an early lead but lost 2-1 at home to the New England Revolution, the Seattle Sounders overcame lowly Chivas USA 2-1, while the Houston Dynamo and the Chicago Fire played out a 1-1 draw.