The Spireites took the lead on 27 minutes when Danny Rowe blasted in a 30-yard free-kick, but the hosts equalised instantly through Kyle Wootton.
Liam Mandeville finished off a great counter just before half-time to put the Blues ahead at the break.
Blues goalkeeper James Montgomery played the last 30 minutes injured and Wootton grabbed his second before Ellis headed the winner to break Chesterfield hearts.
Here are Liam Norcliffe’s player ratings…
1. James Montgomery 7
Made a save from Wootton in the first 30 seconds. Condeded three but two of those came after his injury when he could hardly walk. With no sub goalkeeper on the bench, he carried on playing through the pain barrier for the last half an hour which he deserves a lot of credit for. If he had been fully fit, you would have backed him to have claimed the cross which Ellis headed in from a couple of yards for the 90th minute winner. An extra mark for his courage. Photo: Tina Jenner
2. Will Evans 5
In general play he was fine but he was beaten in the air by Ellis for the second and third goals. Photo: Tina Jenner
3. Gavin Gunning 7
His soft header back to Montgomery almost cost Chesterfield a goal in the first 30 seconds. Notts' first equaliser came when his clearance was charged down. Apart from that he had a good game and made numerous key headers and interceptions. Photo: Tina Jenner
4. Laurence Maguire 6
Didn't have his best game defensively but left everything out there. Made one great block to deny Wootton from close-range at 2-2 late on. Came very close to equalising deep into injury time. Photo: Tina Jenner