Ricardo Vaz Te's late header put West Ham United into the Capital One Cup fourth round after Cardiff fought back from 2-0 down.
Ravel Morrison slid in Matthew Jarvis's cross after 60 seconds.
Jarvis added the second from Modibo Maiga's assist and Craig Noone hit back with a curling 20-yard shot.
Summer signing Peter Odemwingie opened his Cardiff account to level, but Vaz Te scored his second League Cup goal this season to settle the encounter.
Two days after losing to a late Tottenham winner in the Premier League, Bluebirds manager Malky Mackay made 11 changes.
And the Hammers took an early advantage. Cardiff kicked off but one minute later West Ham boss Sam Allardyce, in his 100th game in charge, was celebrating after Morrison beat Bluebirds captain Mark Hudson before lobbing the ball over goalkeeper Joe Lewis.
The ex-Manchester United player followed his third goal in four starts by beginning the move that led to Jarvis's score.
Morrison found Maiga from the byeline and his pass gave Jarvis the chance to defy two defenders and see the ball squirm over the line.
Maiga, Vaz Te and James Collins squandered more home chances before Noone spectacularly made the most of Cardiff's first chance, curling in with his left foot.
That classy finish and a half-time dressing room meeting with boss Mackay prompted post-break urgency from the visitors.
Jordan Mutch's swerving shot that earned a corner off goalkeeper Adrian's save underlined Cardiff's threat.
And Mutch's run and cross gave Odemwingie the close-range chance to score for his new employers.
However, as extra time loomed Jack Collison's cross allowed Portuguese Vaz Te to head the winner.
Cardiff City manager Malky Mackay: "We had a mountain to climb with the way we started.
"I thought we were a shadow of ourselves in that first period but we scored a beautiful goal on the stroke of half-time to bring ourselves back into it.
"We had a conversation at half-time and certainly put West Ham on the back foot in the second half.
"To quieten the crowd to that extent at 2-2, I'm very proud of the players."