Match ends, Birmingham City 4, Rotherham United 2.
Birmingham City scored three first-half goals to help send Rotherham United to a club-record seventh successive away defeat.
Captain Michael Morrison and Lukas Jutkiewicz scored for Blues with headers, either side of Danny Ward's low shot for the visitors.
But Jacques Maghoma's stunning strike gave City a two-goal interval cushion.
Although Jon Taylor's goal led to an uncomfortable final half-hour, David Cotterill's late penalty sealed it.
That decision - as Blues substitute Che Adams went down under a challenge from visiting keeper Lee Camp - looked debatable, but it ensured a sixth straight league defeat for the Millers, who have now conceded 23 goals in seven away games this season.
Their seventh straight loss on the road breaks a club record going back 95 years.
The marking for both Birmingham's two headed first-half goals was poor, the hosts taking the lead when Morrison got on the end of Jonathan Grounds' cross, before Cotterill crossed for Jutkiewicz to finish his fourth goal in eight games from close range.
Jutkiewicz's goal came just four minutes after Ward had levelled with a low right-footed shot from inside the box.
The Millers could do little about Maghoma's goal, however, a superb run and low right-foot shot curled from outside the box into the bottom right corner.
After Ward's knockdown had been poorly defended, Taylor squeezing home a low left-foot shot on 56 minutes, Rotherham had chances to level.
But the late penalty ensured a sixth win of the season - and a rise of one place to fifth in the Championship table.
Birmingham City boss Gary Rowett told BBC Sport:
"We've maybe got away with one tonight. We played well in some spells, but I was actually really disappointed with some aspects.
"As a team we didn't defend well as we'd have liked. The crowd went edgy and another night we could easily have been dragged back to 3-3.
"But these are the sort of games we might have struggled to win last season and we scored goals when we needed to."
Rotherham United boss Alan Stubbs told BBC Sport:
"We played a big part in the game. Going forward we played some good stuff and we can score goals, but our problem is conceding them.
"We shoot ourselves in the foot by getting bullied and outmuscled. Schoolboy stuff.
"It's not teams cutting us open, it's defensive errors, lapses in concentration and we keep making those same mistakes on a regular basis."
- 11CotterillSubstituted forRobinsonat 87'minutes
- 19MaghomaBooked at 80mins
- 9DonaldsonSubstituted forAdamsat 73'minutes
- 15JutkiewiczSubstituted forBrownat 64'minutes
- 16WilsonSubstituted forHalfordat 14'minutes
- 14BallBooked at 77mins
- 17FisherBooked at 54mins
- 4VaulksSubstituted forBlackstockat 84'minutes
- Chris Kavanagh
- Shots on Target
Second Half ends, Birmingham City 4, Rotherham United 2.
Attempt saved. Reece Brown (Birmingham City) header from the centre of the box is saved in the top centre of the goal. Assisted by Jacques Maghoma with a cross.
Foul by Greg Halford (Rotherham United).
Che Adams (Birmingham City) wins a free kick in the defensive half.
Attempt blocked. Maikel Kieftenbeld (Birmingham City) right footed shot from outside the box is blocked. Assisted by Stephen Gleeson.
Corner, Birmingham City. Conceded by Isaiah Brown.
Darnell Fisher (Rotherham United) wins a free kick in the defensive half.
Foul by Reece Brown (Birmingham City).
Attempt missed. Danny Ward (Rotherham United) left footed shot from the left side of the box is close, but misses the top left corner.
Attempt blocked. Danny Ward (Rotherham United) left footed shot from the centre of the box is blocked. Assisted by Darnell Fisher with a cross.
Substitution, Birmingham City. Paul Robinson replaces David Cotterill.
Foul by Dexter Blackstock (Rotherham United).
Ryan Shotton (Birmingham City) wins a free kick in the defensive half.
Substitution, Rotherham United. Dexter Blackstock replaces Will Vaulks.
Goal! Birmingham City 4, Rotherham United 2. David Cotterill (Birmingham City) converts the penalty with a right footed shot to the bottom right corner.
Penalty conceded by Lee Camp (Rotherham United) after a foul in the penalty area.
Penalty Birmingham City. Che Adams draws a foul in the penalty area.
Foul by Isaiah Brown (Rotherham United).
David Cotterill (Birmingham City) wins a free kick in the defensive half.