Ricardo Vaz Te scored a late winner as West Ham survived an unlikely comeback to beat Cardiff 3-2 in the Capital One Cup.
The Hammers were two up and cruising with seven minutes gone thanks to goals from Ravel Morrison - after just 20 seconds - and Matt Jarvis.
City had made 11 changes to their line-up from the team narrowly beaten by Tottenham on Sunday, and they played like strangers as West Ham threatened to run riot in the first half.
Modibo Maiga, Vaz Te and James Collins should all have put the game to bed before the interval.
But somehow the score stayed the same until the stroke of half-time when Craig Noone halved the deficit with Cardiff's first attack of the match.
And midway through the second half they found an equaliser when Peter Odemwingie scored on his full debut for the club.
But three minutes from time Vaz Te converted a cross from Jack Collison and ensured it was the Hammers who made it through to the fourth round.
There was little sign of the drama to come when Morrison stunned the visitors with a goal straight from their own kick-off in an amazing start to Sam Allardyce's 100th match in charge.
His first game as Hammers boss two years ago was a home defeat by Cardiff, but any chance of repeat was already looking unlikely.
Morrison collected a through-ball from Jarvis and ran at stand-in City skipper Mark Hudson, cutting inside the centre-half before lifting the ball over Joe Lewis and into the net.
It was the former Manchester United youngster's third goal in four starts for the Hammers, as he continues to soften the blow of record signing Andy Carroll's absence through injury.
Jarvis doubled the lead following a slick move this time started by Morrison, who spun away from John Brayford and knocked the ball to Maiga on the byline.
Maiga's first-time pass found Jarvis in front of goal and despite two Cardiff defenders sliding in to block, the winger's effort eventually rolled over the line.
And the rampant hosts could, and probably should, have had five or six before half-time.
Vaz Te saw a volley superbly palmed away by Lewis and, from the corner, Collison found the ball at his feet in front of goal but poked it wide.
The much-maligned Maiga, still yet to score this season, then broke clear only to drag his shot across goal, and Collins missed an open goal from three yards after James Tomkins had headed Collison's cross back into his path.
And then, from out of nowhere, Cardiff pulled one back on the stroke of half-time with their first attack of the game.
There seemed little danger when Noone collected the ball out on the right but the winger unleashed a superb 20-yard curler with his left foot which flew past Hammers keeper Adrian and into the net.
Cardiff looked a different team after the break and Jordan Mutch's swerving effort produced an unconvincing save from Adrian before, from the corner, former Hammer Nicky Maynard sent an overhead kick straight at the Spaniard.
And the equaliser came in the 75th minute when Mutch drove into the area and crossed for Odemwingie to tap in his first goal since his infamous failed drive to QPR to try to force a January move from West Brom.
However, Vaz Te, who himself requested a transfer in the last window, had the final word when he got his head onto Collison's cross to send the Hammers through.