Steven N'Zonzi slotted home the decisive spot kick after the 10-man Championship outfit had battled back from 3-1 down to take the fourth round matchup to penalties.
Stoke had been 3-1 up Tuesday, following the first-half dismissal of Birmingham’s Wade Elliott, but two late Peter Lovenkrands goals took the game to extra time.
Kenwyne Jones then put Stoke back in front but substitute Olly Lee got a 118th-minute equalizer, his first senior goal, to take the game to penalties.
Birmingham missed its first two spot kicks, from Mitch Hancox and Callum Reilly, and though it converted the third and fourth, Stoke scored each of its first three, leaving Steven N'Zonzi to step up and fire home the winner, sending the visitors through to just their second League Cup quarterfinal since 1978-79.
Stoke boss Mark Hughes made five changes from Saturday’s defeat at Old Trafford and two of his inclusions - Marc Muniesa and Ousama Assaidi - combined to put the Premier League outfit in front after nine minutes.
Muniesa ran onto Marko Arnautovic's perfectly weighted through ball, before back-heeling into the path of Assaidi who fired an excellent 20-yard strike straight into the top corner for his first goal for the club.
The hosts drew level 28 minutes in when Tom Adeyemi got onto a Nikola Zigic knockdown and finished well past Thomas Sorensen.
But, in first-half injury time, a clash between former Burnley midfielder Elliott and Assaidi left the Moroccan winger in a heap and his Stoke teammates incensed. Referee Simon Hooper subsequently showed Elliott a red card.
Stoke took full advantage of the dismissal when Peter Crouch met Muniesa's whipped cross, steering his header back across Colin Doyle and into the far corner of the net.
Arnautovic looked to have put some gloss on the result with a superb strike from just inside the box after latching onto N'Zonzi's pass with 19 minutes remaining.
Stoke should have been out of sight by that point, but the hosts pulled one back through Lovenkrands in the 85th minute and Lee Novak drew a great save from Sorensen a minute later as they pushed for a leveller.
Hughes' men looked to have done enough but, with three of the five minutes of injury time gone, Lovenkrands latched onto Demarai Gray's pass and fired home a sensational equalizer.
Stoke again went ahead in extra time as Jones turned well and rounded Doyle before finishing into the empty net from a tight angle.
But, unbelievably, the 10-men of Birmingham came back again and equalized through Lee with just two minutes of extra time remaining, setting up the dramatic shootout that saw Stoke finally claim a hard-fought win.