Manchester United crashed out of the Carabao Cup in a 2-1 defeat to Bristol City as Korey Smith scored a dramatic stoppage-time winner to send the Championship side into the last four.
Despite naming a strong line-up that included Paul Pogba, Jose Mourinho saw his team fall behind to a spectacular opening goal by Joe Bryan before Zlatan Ibrahimovic fired home an equaliser.
Substitute Romelu Lukaku had chances to win it for United but with extra-time looming, Smith struck the decisive blow with the last kick of the game to land them a semi-final tie with Manchester City.
Bristol City have become just the second team to knock out four top-flight sides in one League Cup campaign.
Eight months to the day since he seriously injured his knee, Ibrahimovic was at the thick of the action early on. Anthony Martial's back-post cross found the striker, whose knock back deflected off Nathan Baker and against the crossbar.
Bristol City: Steele (7), Wright (7), Flint (7), Baker (7), Magnusson (7), Brownhill (7), Smith (8), Pack (7), Bryan (9), Paterson (7), Reid (7).
Subs: Taylor (6), Eliasson (6)
Manchester United: Romero (6), Darmian (6), Shaw (6), Rojo (6), Lindelof (6), Blind (7), McTominay (5), Pogba (6), Rashford (6), Martial (5), Ibrahimovic (6).
Subs: Lukaku (7), Mkhitaryan (6), Smalling (N/A)
Man of the Match: Joe Bryan
Rashford then rattled the woodwork on 21 minutes with a thunderous low strike, before Daley Blind denied Smith with a well-timed last-ditch tackle when the midfielder had skipped through on goal.
United lacked rhythm in their play and it was the energetic visitors that maintained their front-foot approach after the break and they got their reward on 51 minutes.
Bryan picked the ball up inside his own half and instigated a counter with a clever flick over Blind. He followed his run and produced a stunning strike from a tight angle into the top corner.
Bristol City made just one change, with Luke Steele returning in place of Frank Fielding in goal. Meanwhile, Jose Mourinho changed 10 players with Paul Pogba and Zlatan Ibrahimovic among the starters.
United were behind for just eight minutes as Ibrahimovic celebrated his return with a powerful 20-yard strike from a free-kick on the edge of the area after Pogba was felled.
Mourinho sent on Lukaku and Henrik Mkhitaryan in search of a winner. Lukaku made a big impact, testing Luke Steele with three efforts that the goalkeeper got down quickly to. The third on 83 minutes was an outstanding one-handed save down to his left as Bristol City started to sink deeper but created one last chance, which they sensationally took.
Matty Taylor was given space down the left and his cross dropped for Smith inside the area. He kept his composure and fired a low effort past Sergio Romero.
Ashton Gate erupted.
Man of the match: Joe Bryan
There was only one left-back on show here that looked like he cost £30million and it wasn't Luke Shaw.
Bryan, who came through the youth ranks at Ashton Gate and has made over 200 appearances, has been instrumental this season in their rise up the Sky Bet Championship and put in a near-faultless display that included a wonder goal. There was only one place Bryan could have squeezed his shot past Romero from 20 yards and he found it with exquisite precision and explosive power. More performances like this and he won't be a Championship player for long.
Lee Johnson: "I thought at times tonight we looked like the Premier League side. The way we passed and moved and the speed on the counter attack. Our goalkeeper had to make two or three fantastic saves but that was always going to happen."
Jose Mourinho: "They were a bit lucky. But they fought a lot to be lucky. They won the game in our best moment, where we can't react, when everyone was waiting for our goal. So I have to say they were a bit lucky. Also in the first half we hit the post twice. But they played brilliantly, fought like this was the game of their lives, which it probably was, and I think a beautiful day for football, because a team from a lower division one. To get into a semi-final, a big day for them, their supporters."
- Manchester United have been knocked out in four of their last seven League Cup ties against sides from a lower league.
- The Robins have now scored 16 goals in this League Cup campaign - more than any other side in the competition.
- Bristol City became only the second lower division side to knock Man Utd out of the League Cup as holders, after Southend United in 2006-07.
- City are only the second lower league side Jose Mourinho has lost to as a manager in England, after Bradford in the 2014-15 FA Cup with Chelsea.
Manchester United are back in front of the Sky Sports cameras on Saturday night with a trip to Leicester while Bristol City are back in Sky Bet Championship action against QPR.