Bruno Fernandes sent Manchester United into the League Cup last 16 as the Portugal midfielder punished a howler from Aston Villa keeper Robin Olsen in Thursday's 4-2 win.
Erik ten Hag's side were in danger of losing to Villa for the second time in a week after trailing twice in the third round tie at Old Trafford.
Beaten 3-1 by Villa in the Premier League last weekend, United fell behind to Ollie Watkins' second half opener.
Anthony Martial equalised but Diogo Dalot's own goal restored Villa's lead in their second match under new boss Unai Emery.
Marcus Rashford hit United's second equaliser and Fernandes put them ahead after Olsen's woeful pass went astray before Scott McTominay wrapped up the victory in stoppage-time.
Ten Hag had said he wanted a "reaction" after branding United's limp loss at Villa Park as "not acceptable".
The United manager got his wish, but not before a scare from Emery's team, who have played with more verve since the Spaniard arrived from Villarreal to replace the sacked Steven Gerrard.
"Happy with that resilience. That's what we need and have to show every game. I was so disappointed and mad on Sunday because we didn't fight," Ten Hag said.
"Our two halves are never the same. Tonight we controlled the game in the first half by good pressing but then did the wrong things, so we missed a lot of opportunities.
"At half time we said keep the pressing but be more direct. I'm proud of the team we could do that. We are in the right direction but still a long way to go."
The League Cup remains United's last domestic trophy triumph in 2017 and Ten Hag would relish the chance to end that drought later this year.
He will have to wait until after the World Cup for United's next League Cup tie against Burnley, with the last 16 scheduled for just days after the final in Qatar.
Holders Liverpool have been handed a trip to Manchester City in a high-profile last 16 clash, but both teams are likely to feature youthful line-ups to allow their players extra rest after the World Cup.
Martin Dubravka was making his United debut and the former Newcastle keeper was almost embarrassed as Douglas Luiz's inswinging corner arrowed towards the near post, where McTominay headed off the line to spare the Slovak's blushes.
- United hit back –
That near-miss was the highlight of a scrappy first half as each teams surrendered possession more than 60 times.
The entertainment level rose dramatically after half-time.
Villa took the lead in the 48th minute when Jacob Ramsey's pass caught United in a failed attempt to play offside.
Watkins sprinted in behind Harry Maguire and Dalot before clipping a deft finish over Dubravka.
United produced the perfect response with an equaliser 60 seconds later.
Picked out by Dalot's pass, Fernandes got behind the flat-footed Villa defence and squared for Martial, who had the simple task of tapping in his fourth goal this season.
Villa went back in front after 61 minutes when former United defender Ashley Young crossed to the far post, where Dalot stuck out a boot to deflect Leon Bailey's header into his own net.
On the day his place in England's World Cup squad was confirmed after his renaissance this term, Rashford bagged the 67th minute equaliser.
Rashford started the move with a header towards Christian Eriksen in the Villa area.
When the ball rolled back to him, Rashford showed a deft touch to evaded Tyrone Mings' lunge and then displayed his strength by holding off Calum Chambers before ramming his close-range finish past Olsen.
United had all the momentum by that point and Fernandes completed their comeback in the 79th minute.
Olsen's horrendous pass went straight to Alejandro Garnacho and he set up Fernandes for a powerful strike that deflected in off Mings.
In stoppage-time, McTominay volleyed home from a pin-point cross by eye-catching substitute Garnacho.