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.
West Ham facts
Ricardo Vaz Te's winner was his 14th goal for West Ham and second in the League Cup this season.
He scored in the 2-1 win over Cheltenham in August, with Ravel Morrison scoring the winner that night.
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."
- 13 Adrian
- 03 McCartney (Rat - 82' )
- 05 Tomkins
- 19 Collins
- 37 Chambers
- 07 Jarvis
- 14 Taylor
- 15 Morrison (Diame - 58' )
- 10 Collison
- 11 Maiga (Petric - 46' )
- 12 Vaz Te
- 25 Henderson
- 08 Rat
- 04 Nolan
- 21 Diame
- 33 Ruddock
- 34 Moncur
- 30 Petric
- 32 Lewis
- 02 Connolly
- 05 Hudson
- 12 Brayford (McNaughton - 46' )
- 42 John
- 11 Odemwingie
- 16 Noone
- 18 Mutch
- 19 Cowie
- 20 Mason (Smith - 56' )
- 23 Maynard (Gestede - 90' )
- 33 Moore
- 25 McNaughton
- 24 Lappin
- 40 Harris
- 14 Smith
- 15 Gestede
- 46 Healey