Tom Kennedy's last-gasp winner gave the home side the three points and left Chesterfield heartbroken.
The visitors' best player, Jamie Ward, looked to have rescued a point for the Spireites with a wickedly struck free-kick, but then blotted his copy book in stoppage time by picking up two yellow cards for blatant time-wasting inside 90 seconds and was subsequently sent off.
The game started evenly and was played at a high tempo throughout with home keeper Sam Russell making good saves from Phil Picken and Ward.
At the other end, Chesterfield keeper Trevor Carson did well to keep out Gary Jones' shot and somehow kept the ball out of his net in a goalmouth melee just before the break.
The home side broke the deadlock on 67 minutes with a goal that had more than a touch of fortune about it as teenager Will Buckley saw his mis-hit cross loop over the stranded Carson and into the roof of the net.
Before that Russell had produced an incredible close-range save to keep out Gregor Robertson and, after Buckley's goal, Ward missed two glorious opportunities.
The live-wire striker, who seemed to be involved in just about everything in the game, brought his side level on 86 minutes when his powerfully-struck free-kick somehow squirmed through the grasp of Russell.
Deep into stoppage time, Chesterfield keeper Carson fouled home striker Jordan Rhodes and, after first of all Carson and then Ward had been booked and Ward therefore sent off, home full-back Kennedy produced a stunning 20-yard curler to win the game with what was literally the last kick of the match.