Ryan Cresswell headed home an injury-time winner for Rotherham to clinch victory against a valiant 10-man Accrington side in an ill-tempered affair.
Stanley went ahead after nine minutes when Andy Parkinson rounded goalkeeper Andy Warrington and fired low into the far corner.
However, defender Kevin Long then saw red in the 17th minute when he hauled down Adam Le Fondre.
The dispute was whether it was inside the area but referee Geoff Eltringham gave the penalty and Le Fondre fired home his 11th goal of the season.
Stanley re-took the lead after 49 minutes when Jimmy Ryan rifled the ball low into the net.
But with nine minutes to go a Paul Warne corner was headed in by defender Exodus Geohaghon before Cresswell nodded into the net to end Stanley's unbeaten home record.