Rotherham's impressive start to the season came to a heartbreaking halt in the rain at Chesterfield when a stoppage-time header from Alan Goodall earned Chesterfield their first home win of the season.
A match which was full of entertaining and enterprising football from both teams appeared to be heading for stalemate until Goodall got on the end of a long ball from Robert Page in the fourth minute of stoppage time to score.
Rotherham's defence had by then been deprived of both centre-backs through injury, but even so it was a poor goal to concede at the end of a hard fought contest.
Both sides had chances to have won the game before then and, although Chesterfield had the best player on the field in Jamie Ward, Rotherham will look back on some missed opportunities.
Reuben Reid volleyed high over the bar from only 12 yards in the 18th minute and Ryan Taylor should have done better than head wide from close range in the second half.
In between, Ward's movement and tireless running always posed awkward questions for Rotherham, who had to move Pablo Mills into the back four when Nick Fenton stayed in the dressing room at half-time with a stomach problem.
Chesterfield edged the game in terms of passing, but Rotherham always looked capable of stealing a goal with the pace of Reid and the clever movement of new signing Mark Burchill.
The conditions did not prevent the players putting on a good spectacle for a crowd of just under 5,000 and Ward showed why he is rated as one of the best strikers at this level when he almost broke clear only for Fenton to deny him on the half hour.
The second half was shaded by Chesterfield with Derek Niven forcing a fine save from Andy Warrington, who also made good stops from Jamie Winter and Ward.
His agility appeared to have been rewarded with a point but with virtually the last kick of the match, Rotherham's defence switched off and Goodall stole in to head a dramatic winner.