Goals from Helder Costa after 15 minutes and Jack Harrison on 21 appeared to put Leeds in control to end their three-match winless run.
But Jude Bellingham reduced the arrears six minutes later before Lukas Jutkiewicz levelled in the 61st minute.
Luke Ayling restored Leeds’s advantage after 69 minutes and set up Stuart Dallas for their fourth goal six minutes from time, sandwiching Jeremie Bela’s 83rd-minute header.
Jutkiewicz equalised again in the first minute of time added on, only for Wes Harding’s own goal to make it 5-4 four minutes later.
Leeds were without 10-goal top scorer Patrick Bamford after the striker suffered a dead leg in the 1-1 draw against Preston North End on Boxing Day.
In his place, on-loan Arsenal forward Eddie Nketiah made his first Championship start.
Marcelo Bielsa’s side took the lead when they broke on a Birmingham corner.
Harrison collected a loose ball after Liam Cooper nodded away Gary Gardner’s header and surged upfield before threading Costa through to turn Maxime Colin and bury a low, left-foot shot to Connal Trueman’s left into the bottom corner.
Six minutes after his sixth assist of the campaign, Harrison made it 2-0 with his fifth goal of the season.
A cross from the right hit Harlee Dean and Ezgjan Alioski, with his back to goal, teed up Harrison for a half volley that took a hefty deflection off Dean to wrongfoot Trueman.
Birmingham gave themselves a lifeline when 16-year-old Bellingham fired home from 15 yards from Colin’s cross.
Jutkiewicz had a half chance for an equaliser just before half-time when he seized on a loose ball after Dan Crowley had two shots blocked, but the ball wouldn’t come down quick enough and he hooked over the bar.
There was still time for Ayling to steer the ball over at the other end from Kalvin Phillips’ corner.
Birmingham equalised with the first meaningful chance of the second half.
Colin’s corner was nodded goalwards by Kerim Mrabti at the far post and goalkeeper Kiko Casilla parried as far as Jutkiewicz, who nodded home his seventh goal of the season.
Leeds regained the lead when Ayling cut in from the right and lashed an unstoppable swerving shot into the top corner from the edge of the box.
Birmingham pegged them back again when Bela glanced in Pedersen’s free-kick, only for the unmarked Dallas to hook home from Ayling’s pass.
Jutkiewicz sent the home fans delirious when he stabbed home Bela’s cross from close range to make it 4-4.
But Harding continued the drama when he fired into his own net while under pressure from Ayling’s cross.