Sebastian Larsson led Birmingham back to the top of the Championship table after an entertaining game played in awful conditions.
Cardiff shaded the first half as Ricardo Scimeca went close and Michael Chopra had a penalty appeal rejected.
Larsson scored after Matt Sadler's left-wing cross bobbled to the Swede, who poked the ball in from close range.
Colin Doyle did well to deny Roger Johnson before Cameron Jerome and Gary McSheffrey went close to making it 2-0.
Blustery conditions and an uneven pitch did not help the quality of play but the visitors seemed to adapt their game more quickly than the home side.
Doyle should have done better when he could only push away Scimeca's stretched header and minutes later the Birmingham goalkeeper risked conceding a penalty as he bravely dived at the feet of Chopra.
As the half progressed Birmingham upped the tempo, with Rowan Vine coming close to his first goal for the club when he flashed a shot inches wide of the left-hand post after good approach work by Fabrice Muamba.
Birmingham began the second half more positively and as the pitch grew more water-sodden.
It was a scrappy goal that broke the deadlock, Larsson sweeping home Sadler's cross after McSheffrey's effort had been blocked.
Doyle was the home side's hero again when he pushed defender Johnson's opportunistic volley over the bar and from the resulting corner, Chopra's cushioned header was off-target.
Vine was a constant threat before being replaced by Jerome, who almost produced an instant dividend against his former side with his first touch.
Neil Alexander did well to block his goal-bound shot but it only went as far as McSheffrey, who skidded into the post as his effort crept just wide.
Steven Clemence also came close to reinforcing Birmingham's advantage, with a shot that was just off-target, and they held on through four minutes of stoppage time to return to the top of the table.
"The lads dug deep and are determined, none more so than Rowan Vine.
"We've got other teams near the top in the next few weeks, and our record against the top teams is very good."
"At this stage of the season it is sometimes better to be lucky. Their goal could have been offside and we should have had a first-half penalty.
"It was a pudding of a pitch out there. It was a bog. I wouldn't put my horses on it."
Birmingham: Doyle, Kelly, N'Gotty, Martin Taylor, Sadler, Larsson, Muamba (Nafti 72), Clemence, McSheffrey, Vine (Jerome 84), Bendtner. Subs Not Used: Maik Taylor, Gray, Campbell.
Booked: Sadler.
Goals: Larsson 56.
Cardiff: Alexander, McNaughton (Gilbert 88), Johnson, Loovens, Whittingham, Parry, Scimeca, McPhail, Ledley, Chopra, Thompson (Green 79). Subs Not Used: Forde, Walton, Byrne.
Booked: Ledley, Johnson.
Att: 28,223
Ref: K Friend (Leicestershire).