The Rams, who would have gone above Bournemouth with a win, were staring down the barrel after 60 minutes as the Millers put in a rousing performance and led 3-1 thanks to quickfire second-half goals from Richie Smallwood and Matt Derbyshire.
But there was an air of inevitably about the comeback as soon as Tom Ince grabbed his second goal of the game and Derby’s dominance eventually paid off with seven minutes remaining as Darren Bent continued his hot-streak by poking home his sixth goal in six games.
It was harsh on Rotherham, who initially led in the first half through Paul Green’s opener, and were good value for the potential upset and the fact they are the first team to score three against Steve McClaren’s men since August will be little consolation in their battle against relegation.
Millers’ defender Jack Hunt suffered a serious-looking injury, with play held up for six minutes.
The hosts regrouped and forced their way into a 35th-minute lead through former Rams midfielder Green, who tapped in from close range.
But immediately Ince picked up the ball on the right, twisted and turned and then sent a sumptuous effort sailing into the top corner with Adam Collin helpless.
The Millers fired a two-goal salvo within nine minutes of the restart. First Smallwood bagged his first goal for the club in the 49th minute when he delivered a free-kick in from the left, which evaded everyone and sailed into the top corner.
Five minutes later Derbyshire fired low under Lee Grant for his fourth goal in five games.
Just after the hour Craig Forsyth sent in a cross which Ince turned in at the near post and Jesse Lingard’s 83rd-minute centre was knocked home by Bent.
Rotherham United: Collin, Hunt (Richardson 31), Broadfoot, Arnason, Fryers, Pringle (Newton 71), Green, Smallwood, Milsom (Hammill 77), Ward, Derbyshire. Unused substitutes: Loach, Wood, Bowery, Clarke-Harris.
Derby County: Grant, Christie, Keogh, Buxton, Forsyth, Hendrick (Bryson 60), Mascarell (Lingard 59), Hughes, Ince, Bent, Ward (Dawkins 60). Unused substitutes: Roos, Thomas, Shotton, Thorne.
Referee: N Miller (Durham).