Alvaro Saborio's three consecutive goals, including tallies in the 80th and 82nd minutes, had given Salt Lake a late 3-2 lead, but the Red Bulls rallied in the waning minutes.
Fabian Espindola was hauled down in the penalty area by Aaron Maund in the 89th minute and responded with his second penalty-kick goal of the contest, forging a 3-3 tie.
That set up the game-winner by McCarty, who got his head on a cross from Brandon Barklage in the 94th minute and put it past goalkeeper Jeff Attinella.
Tim Cahill also tallied for the Red Bulls (10-7-5), which finished the night tied with Montreal for second place in the Eastern Conference, one point behind Sporting Kansas City.
Western Conference-leading RSL fell to 11-7-4.