The Potters had looked set for a 3-1 victory in normal time at St Andrew's until Blues substitute Peter Lovenkrands scored twice in a stunning finale to send the game to extra time.
Kenwyne Jones again put Stoke ahead just four minutes into the additional period before, amazingly, the Sky Bet Championship hosts managed to level once more late on courtesy of Olly Lee to make it 4-4 and round off an incredibly dramatic 120 minutes.
Stoke eventually progressed 4-2 in the subsequent penalty shoot-out to book their place in the last eight, much to the relief of Hughes, who celebrates his 50th birthday on Friday.
"Credit to Birmingham, I thought they were magnificent," Hughes said. "They kept on going and they were a credit to their manager and their club.
"With them being down to 10 men we got into a position where we are 3-1 to the good with 20 minutes to go, we should see the game out quite comfortably.
"But for whatever reason - maybe we lost a little bit of focus and ally that to the attitude and endeavour of Birmingham - we allowed them back into the game.
"I'm sure the neutral thought it was a fantastic game, from my point of view it was awful.
"You think the game's done and dusted and it should be, we need to be able to see out games in those circumstances quite comfortably. We showed an unbelievable amount of naivety in terms of what was required to put the match to bed."
Hughes, who won the League Cup with three different clubs as a player, added: "We wanted to be in the next round and we've achieved that but we didn't think we'd have to go through the amount of emotion we've expended.
"It should have been a lot more comprehensive and comfortable for us but we made a dog's dinner of it to be perfectly honest. But we got through so we're grateful for that."
Oussama Assaidi's stunning 30-yard strike handed Stoke an early lead which was cancelled out by a well-worked goal from Tom Adeyemi.
Then came a moment of controversy as Wade Elliott was dismissed amid a mass melee on the stroke of half-time for an apparent elbow on Assaidi.
The Potters made their numerical advantage count in the second half as Peter Crouch headed a second and Marko Arnautovic added a well-taken third.
But, out of nowhere, 2011 winners Birmingham dramatically forced extra time and then penalties.
And boss Lee Clark declared his immense pride with his plucky Birmingham side despite watching them exit the competition.
"You want to win every game and you're hoping the efforts the lads have shown over 120 minutes would be rewarded with the lottery of winning the penalties but it wasn't to be," he said.
"But it doesn't take away from the fact that I'm immensely proud of that group of players, to a man.
"They've given everything, they've ticked every box - pride, passion, work ethic, quality on the ball and never giving in.
"I think the response between the players and the fans and the appreciation between the two showed that."
Source: PA
Source: PA