Tyrone O'Neill gave Boro a 16th-minute lead they took into the break.
Birmingham had the chance to level shortly after half-time but Kyle McFarlane cracked a penalty against the bar.
He atoned by levelling on 55 minutes and Ollie McCoy hit the winner in six minutes later.
The result leaves Birmingham second in Group A on nine points, three behind Derby County, with two teams going into the knockout stages.
But bottom-placed Middlesbrough or Nottingham Forest could still overtake them from their matches in hand.
See: Middlesbrough report
Middlesbrough: 18 Feb v Reading (A) PL2