Moyes had looked set for a nightmare afternoon to eclipse earlier setbacks against West Brom and Southampton when first Peter Crouch and then Marko Arnautovic fired the visitors in front.
But the pressure on the manager's shoulders eased slightly when Wayne Rooney sparked United's late revival with a clipped header from a Robin van Persie corner in the 78th minute - and two minutes later Mexican Hernandez headed the winner from a Patrice Evra cross from the left.
It was hard on Stoke who had stunned the home fans by taking the lead with less than four minutes on the clock and made a mockery of their own paltry goalscoring record this season by attacking with freedom and flair.
But for the brilliance of United goalkeeper David De Gea the visitors could have gone further ahead in a first period in which the home side were plainly nervous and guilty of a series of uncharacteristic defensive mistakes.
When United clawed their way back into the match through Van Persie's equaliser later in the first period, Stoke responded in spectacular fashion by going straight up the other end and restoring their lead through Arnautovic's exquisite free-kick.
Despite their under-par start to the season, United had every reason to feel confident against a Stoke side who had scored just four goals in eight games and came to Old Trafford without a win at the stadium since 1976.
But home hopes that United would quickly settle proved short-lived as the visitors stunned the home fans - including former United boss Sir Alex Ferguson - into silence by taking the lead.
Stoke left-back Erik Pieters took advantage of too much space afforded him on his favoured flank, beating Chris Smalling to cross for Crouch, who bundled the ball past De Gea at the second attempt.
Mark Hughes' side continued to counter-attack with purpose, and went close to adding a barely believable second goal after 13 minutes when Crouch beat Jonny Evans to reach Jonathan Walters' cross from the Stoke right, but spooned over the bar from close range.
Inevitably Van Persie was at the forefront of United's attempted fightback, twice finding dangerous balls into the box blocked by the impressive and busy Robert Huth, while Rooney, anonymous for the first 20 minutes, drilled a speculative shot wide from long range.
The visitors went close again when Crouch nodded a fine ball forward from Steven Nzonzi into the path of the unmarked Walters, whose shot from eight yards was brilliantly saved by De Gea.
Nani was not far away at the other end but a second wasted opportunity from the Portuguese winger sent the first boos of frustration ringing round Old Trafford.
Taking full advantage of United's fragile back-line, Stoke continued to ooze confidence and De Gea had to be on hand again to save a low shot from Arnautovic just past the half-hour mark.
United's next chance fell to Rooney, who twisted a powerful effort from outside the box which was tipped over by Asmir Begovic, matching the heroics of his opposite number.
Last season's champions finally drew level two minutes before the break when Rooney's header from a Patrice Evra cross was kept out by Begovic but the Bosnian goalkeeper could only flap the ball into the path of Van Persie, who buried it from 10 yards.
As if to underline their fearlessness, Hughes' men responded by going straight up the other end and restoring their lead within a minute, Arnautovic sending a delicious 30-yard free-kick into the top corner after being fouled by Smalling.
After the first-half excitement, the game calmed down at the start of the second, with the Potters' understandably sitting deeper and largely coping with what United could throw at them, including a Van Persie free-kick that hit the wall from a dangerous position.
Walters mis-hit a good opportunity for Stoke after a cross from the left by substitute Marc Wilson, and as home frustration grew Hernandez was booked for a bad challenge on an angry Huth.
It fell to Rooney to ease that frustration 12 minutes from time when he applied the deftest of flicks to a Van Persie corner to draw United level - and Hernandez sealed United's quick-fire comeback by heading the winner two minutes later.
So United took the points with a late comeback. That used to be a familiar story around these parts.
Source: PA
Source: PA