Manchester United manager Jose Mourinho. (AFP/Oli SCARFF) |
Mourinho's side trailed to Andros Townsend's early opener and Patrick van Aanholt's second half effort at Selhurst Park.
But Chris Smalling got one back for United and Romelu Lukaku equalised with 14 minutes remaining.
That set the stage for Serbia midfielder Matic to score for the first time since his move from Chelsea last year with a blistering blast from the edge of the area in stoppage-time.
It was an escape act that seemed unlikely when United fell 2-0 behind after being out-fought and out-played by a Palace team fighting gamely to avoid relegation.
But Mourinho took heart from the way his players shrugged off their limp opening to move back above Liverpool into second place in the Premier League and within 16 points of runaway leaders Manchester City.
"You always need that little bit of luck to win a match in the last few minutes," Mourinho said.
"We played very good quality football in the second half but we made so many defensive mistakes.
"That disgraceful, childish second goal changed everything. But the players kept an amazing attitude.
"I cannot tell you half of the things I told my team at half-time because there would be lots of bleeping on television.
"To come back from 2-0 away from home against a team that is desperate for points, it gives us a great feeling."
Third bottom Palace deserved better, but they remain one point from safety after a heartbreaking loss.
United paid the price for their lethargic start in the 11th minute.
Christian Benteke was allowed to jink into the United penalty area unchecked by Smalling and when his pass picked out Townsend 18 yards from goal, the Palace winger unleashed a shot that took a wicked deflection off Lindelof as it looped past David De Gea.
With Matic and Paul Pogba rattled by Palace's relentless pressing, United were unable to match their opponents' intensity.
The out of form Pogba, dropped several times by Mourinho recently, was a major cause of the visitors' woes as the France midfielder wasted possession and was caught out of position time and again.
He was playing so badly that United legend Gary Neville, working for Sky Sports, was moved to say: "It's like everything he does is like a YouTube or Instagram video.
"It's like it's not serious, it's like a joke to him in terms of the way he goes about things."
Mourinho kept faith with Pogba, instead sending on Marcus Rashford for Scott McTominay at half-time.
But just three minutes after the interval, United were caught cold again.
When Palace won a free-kick, Jeffrey Schlupp alertly took it quickly, sending van Aanholt scampering clear on goal.
United appealed in vain for offside but the flag stayed down and van Aanholt held his nerve to slot past De Gea for his first goal since May 2017.
Mourinho was raging on the touchline, but Smalling gave United a lifeline in the 55th minute.
The England defender had missed a good chance moments earlier, but he made amends with a clinical header from Antonio Valencia's cross.
That completely changed the momentum and even Pogba sparked into life as his curler was pushed away by Palace keeper Wayne Hennessey.
Matic almost equalised with a thunderous strike that Benteke cleared off the line and United's pressure was rewarded in the 76th minute.
Alexis Sanchez's shot deflected off James Tomkins and ran to Lukaku, who worked himself into position to fire low past Hennessey.
United were relieved, but it took a brilliant one-handed save from De Gea, diving to his right to keep out Benteke's header, to ensure their comeback wasn't in vain.
The drama wasn't over and in stoppage-time Matic stole the points for United, seizing the loose ball on the edge of the Palace area and cracking his strike into top corner to spark wild celebrations from the visitors.
What the stars mean:
★ Poor ★ ★ Promising ★★★ Good ★★★★ Very good ★★★★★ Exceptional