Despite the defeat, the Millers stay top of the table, but others could now overtake if they win their games in hand.
Accy captain Sean McConville struck in the 75th minute with an acrobatic scissor kick from around six yards out after the Millers had failed to clear their lines.
After a presentation for 20 years in charge of Stanley over two spells for manager John Coleman and his assistant Jimmy Bell, it was a lively first half.
Rotherham frontman Freddie Ladapo had two good chances saved by Toby Savin while Michael Smith had a header cleared off the line by Ross Sykes.
For Stanley, McConville's early blast was blocked, Colby Bishop had a strike ruled out for offside and Ethan Hamilton was denied by keeper Viktor Johansson.
There were scrambles in both boxes after the break and Johansson did well to keep out Stanley's Tommy Leigh on the hour mark after he had raced clean through.
Then came the decider with Leigh's ball into the box causing chaos and McConville pounced.