Cardiff captain Sean Morrison secured a dramatic 3-2 victory over Birmingham with a 90th-minute header.
The Bluebirds defender scored from close range at the death after Harry Wilson levelled the scores 10 minutes earlier.
It looked as if Neil Etheridge was going to deny his former side after he produced a stunning penalty save after Ivan Sanchez had given the Blues the lead with a solo strike, but Birmingham let their lead slip late on.
Cardiff manager Neil Harris was forced into a trio of changes following his side's derby defeat at the weekend.
Joe Ralls, who was serving a one-match suspension after being sent off for two bookable offences during the defeat to Swansea, was replaced in midfield by Marlon Pack.
Robert Glatzel was tasked with providing the goals in the absence of the injured Kieffer Moore as Harris reverted back to a 4-2-3-1 formation that included Gavin Whyte in place of Mark Harris.
Etheridge started in goal for Birmingham against the club he left in the summer in a side containing four changes to the one beaten at home by Watford.