Bolton Wanderers sent West Ham tumbling out of the Carling Cup with a superb 3-1 victory at the Reebok Stadium.
Gary Cahill and Johan Elmander struck in extra-time to send Gary Megson's side through to the fourth round.
It had looked like the Hammers were the ones to be heading through after Herita Ilunga's 59th minute opener, but Kevin Davies grabbed an 86th-minute equaliser to send the tie into extra time.
In an entertaining third-round clash, Kieron Dyer wasted a great chance inside the opening two minutes to give the Hammers a dream start.
Robert Green then pulled off a fine save to tip Zat Knight's header around the post before Zavon Hines was denied by Jussi Jaaskelainen at the other end as the chances continued to flow.
Ivan Klasnic, making his first start for the Trotters, spurned a great opportunity to open the scoring on 27 minutes when he missed an open goal inside the six-yard box.
And the on-loan striker went close moments later, this time Hammers' England goalkeeper Green producing a wonderful save to deny the Croatian.
Wanderers started the second half brightly but failed to turn possession into clear-cut chances.
And West Ham made them pay when Matt Taylor took a wild swing at Alessandro Diamanti's low corner, completely missing the ball to leave Ilunga with the simplest of tasks of prodding home at the far post.
With Wanderers heading out, captain Davies swooped to head home Taylor's corner with just four minutes remaining.
Cahill then put Bolton in front with a blistering half-volley on 96 minutes before Taylor saw his free-kick come thudding back of the foot of the post.
Diamanti clipped the crossbar in the second half of extra-time as the visitors searched for a way back, before Elmander swept home fellow substitute Chung-Yong Lee's low cross in the final minute to wrap up an absorbing contest.