Nahki Wells was a hat-trick hero as caretaker manager Mark Lillis watched Town come from two behind to hit Chesterfield with an extra-time salvo and march into the second round of the Capital One Cup.

The Championship side looked to be heading for a second defeat in four days, this time to League I opposition, before Wells sparked hope of a comeback by putting away a penalty, his second goal of a richly entertaining game, in the 84th minute.

His fellow frontman Jon Stead then fired in a dramatic leveller, which squirmed under the body of keeper Tommy Lee, to rescue Town, who took control as Wells and substitute Joe Lolley scored in the first seven minutes of the additional 30.

Wells’ third was a typical poacher’s effort, fired in when Lee could only parry a fierce Stead shot, then he then played his part in a one-two which ended with Lolley netting his second goal for the club to cap a spirited team performance.

The win was a welcome tonic for Town, who produced the workrate Lillis demanded, but defeat was tough on Chesterfield, who had Ritchie Humphreys, Ollie Banks and Eoin Doyle on target and played their part in a top tie.

Lillis made six changes in the wake of the 4-0 home defeat by Bournemouth which led to Mark Robins’ departure.

With Jacob Butterfield watching on ahead of the imminent completion of his reported £750,000 move from Middlesbrough – Adam Clayton will finally head the other way in a £1.5m deal – his fellow midfielder Conor Coady was handed a full debut.

The £375,000 former Liverpool player operated alongside Ollie Norwood in central midfield in a 4-4-2 formation, with Danny Ward in the right and Sean Scannell on the left.

Tommy Smith (at right-back), skipper Lee Peltier, Murray Wallace and Paul Dixon made up the defence in front of debutant keeper Joe Murphy, with Wells and Stead up front.

Stead, making his first Town start since November, curled an early effort wide, while ex-Town man Gary Roberts had a well-struck effort blocked by Wallace before Romauld Boco volleyed wide as Chesterfield hit back.

This was a pleasingly competitive cup-tie, and the home side came close to going ahead in the 19th minute, when Peltier’s wayward ball let in Roberts, who set up Doyle for a low shot which went narrowly wide.

Ward, fed by Wells, was thwarted by Tendayi Darikwa’s well-timed tackle before bringing a good save from Tommy Lee with a curling shot. At the other end, Murphy had to come out smartly to block at the feet of Doyle.

The breakthrough goal finally came in the 33rd minute – in Chesterfield’s favour.

Veteran defender Humphreys could hardly have placed his header better, meeting left-back Daniel Jones’ cross crisply to give Murphy little chance and find the bottom left-hand corner.

Ward almost conjured a quickfire response, but Lee was equal to his low effort, while Wells should really have done better than shoot straight at the keeper after being set up by Coady, who then had a penalty appeal turned down.

Scorer Humphreys had hobbled off to be replaced by Banks, the son of former Town and Emley midfielder Ian, who needed little time to make his mark.

With the first half in time added on, Sam Morsy pounced on a Norwood slip to find Banks, who bent a 25-yard beauty around Murphy, who again had scant hope of preventing the goal.

Chesterfield started the second half by forcing three corners in quick succession, but Town then pushed forward, and Wells watched in frustration as a well-struck shot was pushed clear by Lee.

But in the 58th minute, the Bermudian was celebrating after heading Town’s first goal of the season from Norwood’s deep cross.

Town brought on Radi Majewski for Scannell after 65 minutes, and the on-loan midfielder soon came close, shooting low on the turn from Stead’s lay-off.

Wells was looking lively as Town threatened, but Chesterfield restored their two-goal cushion in the 72nd minute, Doyle poking home the rebound after Murphy could only parry after a mazy run and shot by Roberts.

Wells drilled over from a Dixon cross before getting the chance to fire in his second from the penalty spot after Stead was fouled by Darikwa in the 84th minute.

Then, in the second minute of time added on, Stead’s shot from the edge of the area squirmed under stopper Lee to send Town’s 853 fans in a 4,569 crowd wild and signal a further 30 minutes.