Dunne headed home Chris Hackett's right-wing cross in the 90th minute after Danny Haynes had tapped home an equaliser on 86, to give caretaker boss Willie Donachie a real chance of landing the job full-time.
Rotherham had led 2-0 through in-form Will Hoskins and captain Ian Sharps.
Ryan Taylor, making his first start for Rotherham, teed up strike partner Hoskins from Michael Keane's left-wing cross but Hoskins' shot bobbled wide.
Taylor then teed up Lee Williamson on the edge of the area, but he could only shoot straight at Lenny Pidgeley.
Haynes then had an audacious overhead kick which sailed over Neil Cutler's goal.
It got worse for Millwall ten minutes later. Williamson's in-swinging cross appeared to be bread and butter for Pidgeley but he lost control of the ball as Rotherham captain Sharps challenged and the ball trickled over the line.
Millwall looked beaten, but four minutes into first-half stoppage time they got a lifeline when Haynes was brought down by Sharps in the box and the striker got up and beat Cutler from 12 yards to give Millwall hope.
Martin Woods had two chances to restore Rotherham's two-goal lead at the start of the second half, but on both occasions he was denied.
Millwall sensed a way back into the game and first Dunne had a shot well saved by Cutler and then Hackett stung the goalkeeper's fingertips with a 20-yard volley.
They got the equaliser four minutes from the end to deny Rotherham the chance to leapfrog them at the foot of the table. Cutler could only parry Dunne's cross and Haynes was on hand to slot home.
Then Dunne struck the winner to keep Millwall off the bottom as he headed down firmly from a right wing cross past the rooted Cutler.