Manager Ronnie Moore hailed Rotherham's "fantastic result" as they came from behind to edge a five-goal thriller at the Crown Ground.
Andy Parkinson fired Accrington ahead but Adam Le Fondre levelled from the spot after Kevin Long was sent off.
Jimmy Ryan rifled home another for valiant Stanley but goals from Exodus Geohaghon and Ryan Cresswell's injury-time header sealed the win.
Moore said: "It was an incredible game, we should have been out of sight in the first half. I think overall no one could complain as we had so many chances and it could have been five or six by half-time.
"You do wonder if it is going to be your day when they made it 2-1. They have done that corner routine a number of times and we had worked on it all week and then we went to sleep. But we used our height to our advantage and have taken advantage of our set pieces.
"It's always pleasing when your centre-backs score with two headers. I think this league is going to be tight this season and set-pieces could be the difference."