Birmingham edged closer to Sky Bet Championship safety after securing a massive 1-0 win at relegation rivals Rotherham.
The crunch game at the bottom was one of few chances, but skipper Harlee Dean's header two minutes from time proved to be decisive.
Rotherham, playing their fourth game in just eight days as they make up for a host of postponed fixtures midway through the season, had the opportunity to close the gap on their visitors but, although they showed the more intent, they were stung by the late winner.
Rotherham remain in the relegation zone and are four points behind Derby, with two games in hand on Wayne Rooney's side.
After stretching their unbeaten run to four games under Lee Bowyer, rejuvenated Birmingham are now nine points above the Millers.
Lukas Jutkiewicz had a chance to give Birmingham the perfect start, but he could not get his first-minute header on target.
Freddie Ladapo had Rotherham's first shot, letting a ball from Lewis Wing go across him before firing just wide from the edge of the box.
Rotherham threatened again, with Wing squaring a ball in low which Angus MacDonald skewed across the face of goal.
Michael Smith should have hit the target from Clark Robertson's cross. The ball fell perfectly for the striker but his effort from 10 yards out flew wide.
Birmingham's main threat had been coming from Marc Roberts' long throws, but a Gary Gardner free-kick flew just over the top of Viktor Johansson's goal.
Rotherham were inches away from taking the lead early in the second half, but Maxime Colin cleared a scrambled effort off the line.
The home side kept up their attacking intent and Dean was the next defender to come to Birmingham's rescue as he managed to block Wing's goal-bound effort from Richard Wood's cut-back.
Jonathan Leko threatened at the other end, but his jinking run in the box was ended by a perfectly timed tackle by Matt Crooks. The resulting corner dropped kindly to Steve Seddon, but he blasted a volley over the top.
Jutkiewicz was then denied at the back post by Johansson as he got his head to Colin's cross.
The vital goal finally arrived on 88 minutes, with Dean rising highest from Roberts' centre, which had been flicked on by Kristian Pedersen, to power a header into the top corner.