Mata fired the visitors in front early in the first half, before Gerrard came on at half-time and was almost immediately dismissed for a stamp on Ander Herrera.
United doubled their lead on the hour mark with a stunning acrobatic second from Mata before Daniel Sturridge pulled one back, and although Wayne Rooney had a penalty saved in the closing moments Louis van Gaal’s side held on to move within two points of second-placed Manchester City.
It ended a run of 13 games unbeaten for Brendan Rodgers’ men, whose last defeat also came at the hands of United when they lost 3-0 at Old Trafford in December.
The result was a massive blow to Liverpool’s top-four hopes as they dropped five points behind their conquerors, who currently occupy the fourth Champions League spot.
It was the visitors who came out of the blocks quickest, and they kept the Anfield crowd quiet by dominating the possession in the opening stages.
United’s pressure paid off in the 14th minute when Herrera’s excellent pass found the run of Mata, who controlled the ball expertly and fired his shot low across Simon Mignolet and just inside the post.
Liverpool were looking nervous and the constant United pressure on the ball meant they were often surrendering possession easily. But United could not press home their advantage and, after being outplayed for the first half an hour, the hosts finally found their feet in the game as Adam Lallana spurned a glorious chance to equalise.
Raheem Sterling set Jordan Henderson away down the right flank, and the midfielder fired an excellent early ball around the visitors’ defence for Sturridge. The striker had a chance to shoot but decided to lay off for the late run of Lallana, but his England team-mate could only drill his first-time effort wide of the target from 18 yards.
That chance brought the crowd into action and Liverpool started to enjoy more time inside the United half, but Van Gaal’s men nearly doubled their lead right before the break as Michael Carrick fired a speculative effort from 25 yards, nearly catching Mignolet out, but the goalkeeper managed to keep it out.
Gerrard was introduced for Lallana at the break as Rodgers looked for some experience in midfield, but 38 seconds after coming on the captain was dismissed as, after flying into a challenge on Mata, he went in for another on Herrera and appeared to stamp down on the United midfielder, prompting a straight red from referee Martin Atkinson.
Liverpool’s response was purposeful and Philippe Coutinho drilled a long-range effort just over the crossbar, but they soon found themselves further behind as Mata grabbed his second in the 59th minute.
The Spaniard squared the ball inside to substitute Angel Di Maria, who returned it with a delightful chipped pass which Mata drove past Mignolet with a spectacular acrobatic volley.
Liverpool managed to haul themselves back into the contest 10 minutes later, however, when Coutinho drove through the middle and found Sturridge, who drove the ball inside the near post aided by a deflection off Phil Jones.
Both sides enjoyed spells of possession as the game twisted and turned, with tempers flaring all over the pitch – substitute Mario Balotelli spared a second yellow card for an altercation with Chris Smalling after picking up an earlier booking for a challenge on Jones.
The visitors were given the chance to kill the game off in stoppage time when Daley Blind got past Emre Can in the box and went down under the defender’s challenge, but Rooney’s shot to the left was easily parried away by Mignolet.
It would not affect the result of the match, which ended on a sour note as Martin Skrtel caught De Gea with a late challenge and the pair squared up, but United took the victory to end Liverpool’s unbeaten run and move five points clear of their rivals.
Gary Neville’s verdict
He’s on for more reasons than one, Steven Gerrard. His one on Mata was a crunching challenge but I think he might have been stupid here; he’ll know from the experience that he has. It’s the emotions sometimes, when you’re playing a fixture like this.
Manchester United: De Gea (7), Valencia (6), Jones (5), Smalling (6), Blind (7), Young (6), Herrera (8), Carrick (7), Mata (9), Fellaini (7), Rooney (6).
Used subs: Di Maria (7), Falcao (6).
Liverpool: Mignolet (5), Can (5), Skrtel (5), Sakho (6), Henderson (7), Allen (6), Moreno (4), Sterling (5), Lallana (6), Coutinho (7), Sturridge (7).
Used subs: Gerrard (1), Balotelli (5).
Man of the match: Juan Mata