The Citizens came to this game as favourites, having progressed through or won their last 21 ties in this competition, last being beaten by local rivals Manchester United in the fourth round in 2016.
Both teams failed to break the deadlock in 90 minutes and a penalty shootout was needed to separate the two sides.
Phil Foden missed one for Guardiola’s men, while the East Londoners scored all five of their attempts to reach the quarter-finals of the competition.
"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,” Guardiola said after the game.
“Phil had the courage to be the first taker but unfortunately he missed it. The experience will help him next time.
"It was one of our toughest games against them. They are doing well in the Premier League, the Europa League and now they are into the quarter-finals of the Carabao Cup.
“They are a fantastic team with a fantastic manager. We played our game and sometimes this happens. When you get to penalties anything can happen. Next season we'll be back."