Chelsea made one change from the weekend's Premiership game at Leicester. Mario Melchiot began his three-game ban, so Albert Ferrer played at right back.
A first half of few chances was livened up with a goal for each side as they went in at 1-1.
After Jermain Defoe's half-volley received a huge deflection off Terry, David James was caught napping by a quickly-taken Jimmy Floyd Hasselbaink free-kick.
Cudicini made an error of his own when he spilled Don Hutchison's low right-wing cross straight into the path of Defoe, who restored West Ham's lead five minutes into the second half.
Albert Ferrer's cross was heading nowhere until Hutchison attempted to head the ball back to keeper James and this allowed Mikael Forssell to nip in and clip a shot past the West Ham keeper.
With both sides pressing for the winner, James recovered to smother Hasselbaink's follow-up effort after spilling Forssell's initial drive, while Cudicini also redeemed himself by tipping over Hutchison's header.
Defoe and Gianfranco Zola were just off target, while Christian Dailly struck the inside of the post and James produced a reaction save to deny Mario Stanic.
Then inside the last minute, with extra-time looming, Terry rose to head home a corner and seal Chelsea's success.
Review the match information and discuss the game on the messageboard.