In-form Lincoln grabbed the silver goal winner to continue their progress in the LDV Vans Trophy.
The Imps' sixth win in seven games was sparked by a goal after just 38 seconds from leading scorer Gary Fletcher.
Chesterfield survived a couple more scares before Chris Brandon got the better of the home defence before firing home a 34th minute equaliser.
Lincoln went back in front early in the second half when Matthew Bloomer's 40-yard pass put Simon Yeo in the clear and the striker finished with a fierce left-foot shot into the top corner.
But Chesterfield levelled things again in the 53rd minute when veteran Paul Warhurst caught out the Lincoln defence with a quickly taken free kick.
Lincoln manager Keith Alexander protested so much that he was eventually sent to the stands by referee Paul Robinson.
Ben Sedgemore had a goal disallowed before Paul Mayo blasted home an 85th minute penalty to put Lincoln back in front.
Brandon, who gave Lincoln problems all night, responded almost immediately with a powerful shot from just inside the box which gave Alan Marriott no chance.
Five minutes into extra time Lincoln got the decider when Richard Liburd fired the ball into the box and, as the Chesterfield defence stood still, Fletcher stole in to flip the ball past Andrew Richmond.
Even then Chesterfield had the chance to get a fourth equaliser but substitute Jamie Cade put his 100th minute shot into the side-netting.