Villa stunned their opponents by taking a two-goal lead through Andreas Weimann in the space of five minutes either side of half-time.
But Hernandez turned the game on its head by scoring United's first goal, seeing his shot deflect off Villa skipper Ron Vlaar for the equaliser, and then heading a late winner.
It stretched United's advantage over nearest rivals Chelsea with another of their famous fightbacks in the face of adversity.
But Sir Alex Ferguson will be concerned United again looked suspect defensively against a Villa side who had scored only eight times in their previous 10 league games.
Summer signing Christian Benteke again impressed up front, while Stephen Ireland looked a threat in his free role behind the main striker.
But United never know when they are beaten and after seldom posing a threat in the opening 45 minutes, the introduction of Hernandez sparked them into life.
They dominated the second period and their persistence finally paid off as they took their goal tally to 29 in 11 league games.
Former Villa winger Ashley Young, who was booed every time he was in possession, then curled a 20-yard shot just wide.
Villa responded and, from the second of three successive corners, Benteke had a shot blocked by Young inside the danger area.
The home side found themselves with a three versus two advantage on the counter-attack but Weimann attempted to find Ireland rather than shooting and the ball deflected through to David de Gea.
Villa fans booed their United counterparts after only a small number clapped during the customary minute's applause for skipper Stiliyan Petrov, who is battling against acute leukaemia.
Ireland flashed a dipping 25-yard drive just past the post after being teed up by Weimann.
Then, in first half injury-time, a superb strike from Weimann put Villa ahead.
Weimann released Benteke, who shrugged off the challenge of Chris Smalling before spotting the run into the box of the Austrian Under-21 international. His rising first-time shot from just inside the box flew past De Gea into the roof of the net.
Ferguson brought on Hernandez for Young at the start of the second half but within five minutes Weimann had doubled Villa's lead.
The England striker's precise ball across the box was smashed home by Weimann at close range.
United reduced the arrears after 58 minutes when Hernandez took a flighted pass from Paul Scholes in his stride and slipped the ball past Guzan for his seventh goal of the campaign.
Scholes headed wide from a Van Persie corner while De Gea held on to Benteke's header from a Weimann cross.
But after 63 minutes an own goal from Villa skipper Vlaar brought United level.
Hernandez was again involved as he got on the end of Rafael's cross but his shot deflected off Vlaar past Guzan into the net.
Villa still threatened danger and De Gea had to palm away Weimann's header from Barry Bannan's cross.
But the woodwork twice came to Villa's rescue in the space of 30 seconds with a Antonio Valencia header and Van Persie's dipping shot hitting the crossbar.
Wayne Rooney picked up a knock and was replaced with 10 minutes left as United pressed for the winner.
It finally arrived in the 88th minute when Hernandez stooped down to head home Van Persie's free-kick.