Rotherham manager Steve Evans reckoned his team could have had seven or eight goals had they put away their chances.
An own goal by Tom Eckersley after 14 minutes set Rotherham on the road to victory but Craig Lindfield equalised five minutes before the break.
But two goals from substitute Daniel Nardiello in 12 second-half minutes put Rotherham back on track and Michael O'Connor added the fourth 14 minutes from time.
Evans said: "It was an important win for us. It was a big three points. For the first 15 or 20 minutes we were outstanding and if we had taken our chances we would have been five up at the 25 minutes mark.
"But it didn't go in for us and patience was wearing a bit thin and we got a bit disjointed and then their boy hit a strike that would befit the Premier League. From then up to half time we just couldn't get our passing game going.
"But the substitutes came on after the break and all of a sudden there was a spark. It helps when you get a goal and when that second goal went in I thought this could be anything we wanted it to be.
"It was a big win for us in the end because this was an Accrington team that went to Bradford and lost 2-1 with ten men and dominated.
"As soon as the second goal went in our fans saw the class come back to our game, but we are going to have games like this because we have been used to dominating teams at home and away.
"I want to thank the fans today for sticking with us, and over the 90 minutes a true reflection would be seven or eight because we missed four or five in the first 20 minutes."