A 13th-minute Ashley Westwood free-kick had shot Villa into an early lead, putting United at risk of succumbing to three consecutive home league defeats for the first time in 35 years.
But after some nervous moments, goals from Rooney, Mata and Javier Hernandez ensured that United will go into Tuesday’s Champions League quarter-final first leg against Bayern Munich with at least a degree of confidence.
United were looking for a response to their 3-0 loss at home to Manchester City in the derby on Tuesday, but after Rafael da Silva tripped Gabriel Agbonlahor, Westwood swept home a magnificent free-kick to put Villa ahead.
It was a potentially disastrous opening for Moyes, who, despite pre-match speculation surrounding his position, had been warmly welcomed by United’s fans.
Moyes emerged to take his place in the dug-out ahead of the players and was greeted with a standing ovation from large sections of supporters.
A few moments after kick-off, an aeroplane flew over Old Trafford trailing a banner that read ‘WRONG ONE – MOYES OUT’.
But, once more, the United supporters actually turned on the publicity-hungry fans behind the stunt, booing the plane rather than their manager.
If that support was welcome, what Moyes really required was an equaliser and, thankfully for the Scot, it came from Rooney with 20 minutes on the clock.
Shinji Kagawa darted towards the area and picked out the unmarked England international with a neat, chipped cross, which Rooney expertly headed past Villa goalkeeper Brad Guzan from 10 yards.
The goal notably lifted manager, players and the crowd at Old Trafford and Mata laid the ball off for Rooney soon after for a fierce 20-yard shot that was bravely blocked by defender Ciaran Clark.
– Mata and Rooney combine
Then Rooney turned provider, clipping over a dangerous free-kick that Nemanja Vidic headed just wide.
Villa were playing without fear, as most visitors to Old Trafford are this season, but Mata and Rooney were always a threat and that combination helped United take the lead moments before the half-time whistle.
After chasing onto Kagawa’s through ball, Mata was chopped down by Leandro Bacuna, prompting referee Martin Atkinson to point immediately to the spot.
Rooney’s penalty kick was as clinical as his earlier header had been, with his right-foot shot easily beating the diving Guzan.
Moyes brought Michael Carrick on for Rafael at the interval, presumably because of an injury to the Brazilian full-back.
Carrick had to slot in at centre-back and he quickly justified his manager’s faith by making a last-ditch tackle to thwart Christian Benteke, who had just miskicked from six yards with the goal at his mercy.
The Villa forward almost made amends minutes later as he rose to meet Marc Albrighton’s right-wing cross and placed a header inches over United goalkeeper David de Gea’s crossbar.
Those misses proved costly as Mata scored United’s third after 57 minutes following a strong header into the area by Alexander Buttner.
Marouane Fellaini miscontrolled the loose ball, but Mata pounced and buried a right-foot snapshot past Guzan from a dozen yards.
Benteke appealed unconvincingly for a penalty after contact from Vidic, and should have done better later as he failed to make telling contact with a long through ball.
United continued to press, though, and after Guzan had repelled powerful attempts from substitute Adnan Januzaj and Rooney, the former crossed from the left for Hernandez to volley home in injury time.