Stoke took an early lead through a Kenwyne Jones header and bossed the game for 30 minutes before letting the home side back into it in the build-up to half-time.
However West Ham failed to make the most of their chances and looked to be heading out of the competition until Scott Parker finally equalised with six minutes of normal time remaining.
Manuel Da Costa and substitute Victor Obinna completed the turnaround in extra time to give Avram Grant a big lift and make it three defeats in a row for the visiting Potters.
Both sides had reverted largely to their line-ups from the previous round, although the Hammers also handed Benni McCarthy his first start in more than seven months.
The South African had the first sniff of a chance in the fourth minute with an air shot from Carlton Cole's knockdown but Stoke took the lead just two minutes later when Jones rose highest to power home Jermaine Pennant's corner.
The home side were demonstrating the defending that had seen them keep just one clean sheet in the league this term, though they went close to levelling in the 13th minute when Cole diverted Pablo Barrera's wayward strike just over the bar.
The lively Cole sent a weak long-range header at Asmir Begovic, while Tuncay got plenty of power but not quite enough accuracy on his effort at the other end.
Tal Ben Haim almost sold goalkeeper Marek Stech short with a backpass with Jones lurking and then incredibly almost gifted the ball to the striker again moments later.
Hammers defender James Tomkins did nod a Barrera corner over the crossbar but Stoke were looking increasingly dangerous on the break and Danny Higginbotham's cross was just too high for Jones to connect with properly.
Like Jones, Cole was looking sharp and a fabulous turn almost saw him equalise but he could not keep down what was a difficult left-foot finish.
There was no such excuse for strike partner McCarthy two minutes before the break when Cole put the ball on a plate only to see the South African produce another air shot.
Glenn Whelan saw a dangerous 20-yard shot deflected behind as Stoke regained control of the match at the start of the second half.
Last-gasp challenges were then needed at both ends as the intensity soared and West Ham should have levelled in the 54th minute when Begovic flapped at Barrera's corner and Tomkins put a diving header just wide.
Stoke immediately brought off Pennant for Danny Pugh, shortly followed by Jones for Eidur Gudjohnsen.
Stech turned behind Tuncay's half-volley from the tightest of angles and Parker - once again carrying West Ham almost single-handedly at times - flashed wide from 25 yards.
Grant then threw on Obinna for Radoslav Kovac in the 64th minute and the home side began to crank up the pressure.
Grant made more changes when he withdrew Luis Boa Morte and McCarthy - to ironic cheers - for Behrami and Noble and Obinna soon forced an athletic parry from Begovic with a 20-yard curler before Stoke shored up their midfield by bringing on Rory Delap for Tuncay.
Cole appealed in vain for an 81st-minute penalty after a coming together with Robert Huth, whose defensive partner Ryan Shawcross was then adjudged to have made the perfect last-gasp tackle on Julien Faubert, much to the home fans' fury.
It mattered not as Parker equalised six minutes from time, nodding home Barrera's inswinging cross from close range and ultimately sending the game into extra-time.
And West Ham completed the turnaround six minutes into the extra period thanks to brilliant work by Noble coupled with appalling Stoke defending.
The midfielder was allowed to burst into the box unchallenged and run along the byline before cutting the ball back for Da Costa - on bail until December on suspicion of sexual and common assault - to rifle home his first goal of the season.
Obinna, who had made a real impact from the bench, was narrowly wide from 20 yards, while Parker was only able to cap a fine run into the area with a weak finish after the change of ends.
Dean Whitehead should have equalised when he blazed over after Jon Walters got away with an aerial challenge on Stech but Obinna sealed victory two minutes from time after being played clean through by Noble.