Chesterfield left it late, but a Tom Denton goal handed John Sheridan victory in the first game of his second stint as manager.
The striker, on as a second half replacement, fired in an 89th minute winner against Bedford Town - his eighth in cup competitions since becoming a Spireite - to send Chesterfield into the third round of the FA Trophy.
A stubborn defensive display meant the Evo-Stik South Division One central side left with plenty of credit, whereas the hosts’ struggle to create chances will have given Sheridan plenty to think about.
The Spireites didn’t emerge unscathed from the tie, midfielder Robbie Weir, who has just returned from a knee problem, went down with a serious looking injury midway through the second half.
The hosts began to assert themselves after several fairly uneventful opening minutes, and created a couple of half chances; Kyel Reid finding Lee Shaw who couldn’t control at the back post, Curtis Weston firing wide from distance.
It wasn’t until the 19th minute that Town tested Ashlee Jones in the away goal, Joe Rowley’s fierce drive from distance pushed round the post brilliantly by the keeper.
Jones was at it again a minute later, getting down well to Reid’s low effort from 16 yards.
Chesterfield were trying to introduce width to their play and Jerome Binnom-Williams showed his pace, cutting in from the left flank and beating two men befre driving a shot against a defender and wide.
Bedford, who lined up in a very defensive formation, struggled to put together any real passages of play, content to lump it clear in the general direction of targetman Paul Benson, who was unable to get hold.
The Spireites didn’t take advantage, however. It should have been 1-0 10 minutes before the interval, the ball falling kindly for Marc-Antoine Fortune about 10 yards out, only for the former Champions League striker to balloon it over.
With a minute left in the half Bedford finally had an effort at goal, Callum Donnelly’s looping volley from 30 yards dipping but still clearing Shwan Jalal’s bar.
Beford’s stubborn, compact defensive shape remained in place after the break, but Chesterfield still found an early opening - Joe Rowley flashing an effort just past the far post from a Reid cross.
That was about as good as it got as the visitors frustrated the National League side and restricted them to playing up to and around the box without creating much.
With 18 minutes remaining Town mustered a shot at goal but Shaw’s low effort was easy for Jones.
Robbie Weir’s afternoon came to a painful end when he was left in a heap on the ground, clutching what appeared to be his knee, forcing John Sheridan into a change, Tom Denton coming on.
Seconds after the change Shaw came close to the opener, his deflected shot from outside the box shaving the woodwork.
Chesterfield continued to toil, failing to open up the side from three divisions below them.
Another long range shot, this time from Reid, whistled past the post.
With time ticking away, a breakthrough finally arrived.
Smith’s deep cross was headed down by Denton, the ball bounced back to him and he lashed home a half volley, beating Jones’ despairing dive and booking Town’s place in the next round.
Fortune butchered a stoppage time chance to double the scoreline and Shaw shot wide on a chance he created for himself, before the final whistle sounded.
Chesterfield: Jalal, Smith, Binnom-Williams, Evans, Hollis, Rowley (Beestin 70), Reid, Weir (Denton 77), Weston, Fortune, Shaw. Not used: Nelson, Anyon, Muggleton.
Bedford Town: Jones, Stephens-Abbey, Freestone. Peters, Dummett, Hoyte, Donnelly (Thorne 90), Ford, Furlong (Penfold 80), Osei, Benson (Gyasi 71). Not used: Hayford, Cooper.
Goalscorers: Denton 89
Yellows: Benson 63
Referee: Mr Simon Mather. Assistants: Mr Paul Tomes, Mr Paul Ince.
Attendance: 2,213 (197 away)