David Moyes’ side held their nerve to successfully convert all five of their attempts to seal a 5-3 shootout victory, as City lost a League Cup tie for the first time since October 2016.
Both teams played their part in an absorbing, keenly contested affair and, whilst both had opportunities to win the game in normal time, it was the visitors who created the majority of the chances at the London Stadium.
City’s best opportunity fell to John Stones, whose six-yard header from a Riyad Mahrez free-kick was superbly saved by the impressive Alphonse Areola, whilst at the other end, Oleksandr Zinchenko, made a crucial block to deny Andriy Yarmolenko after Steffen had beaten away Arthur Masuaku’s fierce drive.
Stones’ effort was one of 25 chances City unleashed on the Hammers’ goal.
After a slow start, the game burst into life midway through the first half following Mark Noble's fizzing 20-yard drive, which stung the palms of Steffen, but that was as good as it got for the hosts in the opening 45 minutes.
City saw several opportunities go begging.
Areola stuck out a leg to keep out Cole Palmer’s angled drive and Mahrez flashed a first-time volley across the face of goal from a tight angle, but the best opportunity fell to Nathan Ake, who rose highest from a free-kick but glanced his header wide of the post from six-yards.
Both teams upped the ante after the break and traded chances in a game which was anything but a boring stalemate.
The Hammers’ goalkeeper got down smartly to keep out the winger’s low drive and adjusted well to save the Belgian’s deflected strike from the edge of the area.
Yarmolenko’s blocked shot was the best of the Hammers’ chances as Moyes’ men began to show more attacking intent.
Masuaku drilled over the bar from an acute angle before Aaron Cresswell and Nikola Vlasic combined to create an opportunity for Tomas Soucek, but the Czech midfielder sent his effort wide from 15-yards.
As penalties loomed large, there was a heart in mouth moment as substitute Foden’s deflected shot dropped into the unmarked Gundogan’s path inside the six-yard box, but the German was caught unaware and Areola gobbled up the loose ball.
The 28-year-old proved to be City’s nemesis and as the game became increasingly stretched, he stuck out a strong hand to tip a stinging 25-yard effort from Zinchenko over the bar.
In the shootout, Joao Cancelo, Gabriel Jesus and Jack Grealish all scored for City, whilst Steffen got a hand to Jarrod Bowen’s effort and did the same with Said Benrahma’s decisive spot-kick, but both had too much pace on them as the Hammers progressed to the quarter-final.
Pep Guardiola: An incredible run has ended
"An incredible run has finished. We finished in a good way. We played in a really good way, creating chances against a team who defended deep.
"On penalties they were better. Congratulations to West Ham. Next year we will be back."
WEST HAM: Areola, Johnson, Diop, Dawson, Cresswell, Noble (C), Soucek, Vlasic (Fornals 61'), Lanzini (Coufal 81'), Masuaku (Benrhama 61'), Yarmolenko (Bowen 61').
SUBS: Randolph, Ashby, Baptiste, Zouma, Chesters.
News about West Ham v Man City
Zinchenko: 'We need to react and bounce back'
Oleksandr Zinchenko is expecting an instant reaction from City following our Carabao Cup defeat to West Ham United. Watch more
Aston Villa v City: Full Match Replay
Watch the full 90 minutes 'as live' Watch more
West Ham v City: Full-match replay
Watch all the action from City's Carabao Cup fourth round clash away at West Ham on CITY+ Watch more