Dan Barlaser's volleyed goal deserved to win the match but in truth, Rotherham should not have done. Thanks to an 88th-minute penalty save from Josh VIckers, Mitch Clark's shot against the post in the seventh added minute and a few other close shaves besides, they did.
Even as they went six points clear at the top of the table, though, it was a far from a perfect day for the Millers. They lost one centre-back, Michael Ihiekwe, to injury and another, Richard Wood, was sent off conceding the penalty Vickers saved.
And yet another incident of moronic behaviour from a Rotherham supporter will have the authorities asking unwanted questions of the club. If follows the disrespecting of a minute's silence at Fleetwood Town and an object thrown at the linesman at Crewe Alexandra.
A supporter ran onto the pitch as Harry Pell lined up his 88th-minute penalty, kicked the ball off the spot, then threw his body at the taker, not brave enough to throw a punch, which was just as well for him. At least one other fan ran on behind him.
The frantic nature of the last 10 minutes were utterly out of keeping with what went before.
For an hour at the New York Stadium, you wondered where a goal was going to come from.
Rotherham were grafting hard - they invariably do - but so were Stanley, and in doing so, they were frustrating the hosts and their supporters almost as much as referee Andy Woolmer was annoying both teams.
For all the Millers' possession, goalscoring chances were proving hard to chisel out.
The ante was upped after the restart as the home side played with more verve but still the game looked deadlocked.
Then, after 58 minutes, a deep free-kick was headed away and Barlaser produced the sort of volley professional footballers dream of.
If you thought that was that, though, you would be very much mistaken.
After Tuesday's stroll in the park at Doncaster Rovers, it was no surprise Stanley were a tougher nut to crack having beaten them twice already this season.
The game took 20 minutes to lift beyond humdrum, Rotherham dominating the ball and Accrington hinting at a counter-attack threat, but none of it amounting to very much.
The only chance of note at that stage was Ross Sykes's header from a free-kick won by Lewis Mansell heading down the inside-right channel - Accrington's most promising avenue - and being brought down by Richard Wood. The header, though, was straight at Vickers.
Woolmer livened the game up, though that was about the only good thing you could say about his erratic performance.
He booked Shane Ferguson in the 20th minute, sprinting off to deal with goodness knows what in the Accrington penalty area and by the time he had, forgetting who he had awarded it against. Even though it was right on the touchline, he did not go over to his linesman but the fourth official on the opposite side to identify the wing-back. At least it was a correct decision, the Northern Ireland international having left a little on his man, but the way it was reached just undermined confidence in a referee who quickly lost control of proceedings.
When Ollie Rathbone was booked three minutes later for another foul, the home crowd were wound up.
In between time Will Grigg had three good chances, collecting a lovely Barlaser pass and producing a shot Toby Savin saved, seeing Sykes clear the follow-up, then ballooning his third go.
Savin's time-wasting antics were a big frustration for the home fans too and it was remarkable it took until first half stoppage time - bizarrely only two minutes - for him to be booked. Even more incredibly, his manager John Coleman complained and met with the same fate.
Although the keeper gave him plenty of goalkicks to linger over, as well as winning their fair share of corners, he had little to do by way of shot stopping.
Rathbone dug a shot out after taking a ball from Wes Harding then exchanging tight passes from Michael Smith, but it went wide.
Rotherham's only other chance of note was a header Michael Ihiekwe ought to have put on target at a corner. Sykes hit a pea-roller at Vickers.
Barlaser's wonderful goal was fitting reward for a livelier start to the second half and when Grigg laid the ball back to Rathbone two minutes later his shot from 25 yards came close to doubling the lead.
Jay Rich-Baghuelou nearly miskicked a Barlaser cross in, but soon Rotherham settled into holding onto their lead and for a long time, it looked like they would.
The first real sign they might not came in the 84th minute when Vickers saved from Sean McConville and Tommy Leigh's shot was cleared off the line.
There was a similar bit of pinball two minutes later but this one ended with Wood given his marching orders as McConville's shot struck his hand.
As Pell lined up the kick, a fan emerged from behind the goal to cause pandemonium. When sanity was finally restored, the spot kick was poor, and Vickers smothered it well.
A lovely Rathbone pass released Ben Wiles one-on-one but Savin came out on top and the rest of the eight added minutes were inevitably played at the other end.
In the seventh of them, Clark struck the post in another scramble.
Rotherham had ridden their luck and come out winners.
Rotherham United: Vickers; Harding, Wood, Ihiekwe (Mattock 62); Barlaser; Ogbene, Wiles, Rathbone, Ferguson (Miller 73); Smith, Grigg (Kayode 77).
Unused substitutes: Johansson, Lindsay, Odoffin, Ladapo.
Accrington Stanley: Savin; Sykes, Nottingham, Rich-Baghuelou; Conneely (Leigh 62), Clark, Butcher, Hamilton; Amankwah (Pell 38), McConville; Mansell (Adedoyin 50).
Unused substitutes: Rodgers, O'Sullivan,Isherwood, Longelo.
Referee: A Woolmer (Northamptonshire).