After 21 ties and 1826 days without defeat in the competition, the Citizens' exceptional era of dominance finally came to an end in front of a sell-out crowd at the London Stadium.
Pep Guardiola's side dominated throughout the encounter, with 65% possession and 25 shots on goal, however the likes of Kevin De Bruyne, Raheem Sterling and Phil Foden were unable to breach a resilient Hammers backline.
The clash finished goalless after 90 minutes with both sides having to settle the tie on penalties. City would have been confident of success from 12 yards, having won each of their last four EFL Cup penalty shootouts under Guardiola.
However, Foden fired City's first spot kick wide to give West Ham the advantage, and David Moyes's men went on to score all five of their efforts from 12 yards, with Said Benrahma converting the decisive penalty to seal a famous victory for the Hammers and book their place into the quarter-finals.
West Ham have now eliminated both Manchester clubs in this year's competition, after beating Manchester United 1-0 at Old Trafford in the previous round, meaning that the 2021-22 trophy will be lifted by a club from outside of Manchester for the first time since 2015.
London rivals Arsenal, Chelsea and Tottenham Hotspur are all potential opponents for the Hammers in the last eight, while Liverpool, Leicester City, Brentford and League One outfit Sunderland will also be in the hat for Saturday's quarter-final draw.