Goals from Andros Townsend and Patrick van Aanholt left Palace in the driving seat early in the second half, but United showed remarkable resilience to prevent defeat and claim all three points right at the death thanks to Matic, reclaiming second place from Liverpool in the Premier League.
Although there was more than a hint of fortune about it, United went behind after just 11 minutes, as Townsend's strike from the edge of the area was deflected in.
Van Aanholt then blasted past David de Gea after taking advantage of the visitor's lack of concentration at the back, leaving United facing the prospect of suffering a third successive Premier League away defeat for the first time since January 1996.
But an excellent Chris Smalling header soon after reduced Palace's lead and that led to a United onslaught, with Romelu Lukaku then showing great patience when drawing the away side level 14 minutes from time.
It seemed Palace had done enough to hold off United's advances and clinch a draw, but Matic stepped up in stoppage time, lashing in his first goal for the club from long range to clinch an unlikely victory and put Mourinho's side back up to second ahead of Sunday's (AEDT) clash with Liverpool.