After a first half of almost total Rotherham domination in which they squandered four or five good chances the home side had to settle for turning round on level terms.
James Beattie cleared off the Stanley line in the first minute, Alex Revell headed just wide and Kieran Agard blazed over the bar inside the first five minutes.
But when Rotherham finally went ahead in the 14th minute it came from an own goal, Tom Eckersley heading Kari Arnason’s long throw over his own goalkeeper.
Revell saw another goal bound effort deflected for a corner and on-loan keeper Cameron Belford made a great save to deny Agard.
And how Rotherham paid for those missed chances five minutes before the break when Michael Liddle’s cross found Craig Lindfield on the edge of the area and he had time to set himself before planting his shot in the top corner of the net.
Rotherham took the lead again in the 62nd minute and again it came from an Arnason long throw. This time the ball was headed up in the air and substitute Daniel Nardiello headed the dropping ball past Belford.
And that opened the floodgates for Rotherham. Nardiello added his second and Rotherham’s third from Agard’s cross after 74 minutes and Michael O’Connor made it four two minutes later firing home after his corner was cleared straight back to him on the corner of the box.