TOWN were knocked out of the Johnstone's Paint Trophy on penalties after scoring twice in stoppage time to force the shoot-out.
Lee Clark's side looked down and out when they trailed 3-1 with the game passing the 90-minute mark.
But Anthony Pilkington, with his second goal of the second-round tie, reduced the arrears direct from a free-kick two minutes into stoppage time.
Then, with the clock showing 93 minutes, Nathan Clarke lashed home a shot after the ball broke loose from a corner.
All the goals came in the second half as Drew Talbot scored either side of Pilkington's 64th-minute volley before substitute Jordan Bowery made it 3-1 in the 89th minute.
In the shoot-out, Robbie Williams and Antony Kay netted for Town, but Pilkington shot over and Jim Goodwin's effort was saved, allowing Chesterfield to wrap up their 4-2 win without the need to take all five spot kicks.
Jamie Lowry, Jack Lester, Dan Gray and Donal McDermott were their successful penalty takers.