The Potters had looked set for a 3-1 victory in normal time at St Andrew's with the home side down to 10 men after Wade Elliott saw red, 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 but Olly Lee made it 4-4 to round off a 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.
"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."
Birmingham boss Lee Clark declared his immense pride with his plucky 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 the 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."