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 found themselves trailing 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 visitors' 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 Saturday's clash with Liverpool.
An end-to-end start to proceedings seemed to promise an open and expansive contest, James Tomkins going close with an overhead-kick in the fifth minute shortly before Alexis Sanchez was denied at point-blank range by Wayne Hennessey.
But a one-sided pattern emerged once Palace took the lead through Townsend – his 18-yard effort finding the top-right corner and leaving De Gea helpless thanks to a sizeable deflection off Victor Lindelof.
Palace sat back thereafter, inviting pressure onto themselves and United obliged by taking complete control of possession.
Yet, for all their time on the ball, Mourinho's side created precious little to worry Hennessey in the Palace goal.
Jesse Lingard was the closest any United player went before the break, dragging a 25-yard effort harmlessly wide of the bottom-left corner in the 40th minute.
Mourinho responded to United's underwhelming first half by introducing Marcus Rashford for Scott McTominay at the break. But within three minutes, Palace punished slack defending to go 2-0 up.
Jeffrey Schlupp's quick thinking at a free-kick just inside the United half allowed Van Aanholt to charge clean through on goal and he produced an emphatic finish to beat De Gea, who was rooted to the spot.
But United responded well and pulled one back in the 55th minute – Smalling, who had threatened just a few moments earlier, meeting Antonio Valencia's cross with a fine header to usher in another period of dominance for Mourinho's men.
Christian Benteke cleared off the line from Matic but Palace's resolve was destroyed in the 76th minute as Lukaku wiped out their lead by taking his time and firing through a crowd of players after a deflected Sanchez effort came back off the crossbar.
De Gea had to be alert soon after to produce a remarkable stop from a Benteke header and that proved decisive, as United went on to claim all three points.
Space opened up for Matic in the first minute of stoppage time and he sent a ferocious effort into the top-left corner from 30 yards, sparking huge celebrations on the United bench and wrapping up an incredible win.
Key Opta stats:
- Manchester United came from 2-0 down to win a Premier League game for the first time since December 2013 (away to Hull City).
- This was also Crystal Palace's first ever Premier League defeat in a game in which they led by two or more goals.
- United are unbeaten in all 18 Premier League meetings between the sides, the most a side has faced another without defeat in the competition.
- Romelu Lukaku's equaliser was his 99th goal in the Premier League, and the first time he's scored in back-to-back league games since December.
- Crystal Palace have now lost all nine Premier League games not to feature Wilfried Zaha this season, by an aggregate score of 3-21.
- Eight of Andros Townsend's 14 Premier League goals have been from outside the box.