Tom Naylor gave the Spireites the lead after half an hour but Trey Ogunsuyi equalised in first-half added-time with a header.
Shrewsbury went in front with 20 minutes remaining when an error from Zach Hemming allowed Ogunsuyi to force home but substitute Tom Pearce levelled with a stunning curling free-kick on 85 minutes.
But there was one more twist when Sam Stubbs headed in on the 93rd minute to pinch the three points for the visitors.
The result is damaging for Chesterfield’s promotion hopes as they fall out of the play-offs.
Here are our player ratings from the game...

9. Dilan Markanday 6
Dilan Markanday 6 Had Town's first shot on target with an attempt from distance which Cox dealt with. Mixed up his game by staying wide and playing inside. Grabbed the assist for Naylor. Quieter after the break. Photo: Tina Jenner

10. James Berry 6
James Berry 6 Some flashes of Berry being at his best with some exciting wing play, drawing two saves from Cox. Not everything came off but he tried to make things happen. Missed a big chance with his head in the second-half when he met Naylor's inviting cross. Kept getting in there. Off on 78. Photo: Tina Jenner

11. Will Grigg 6
Will Grigg 6 Put himself about intelligently as he put the Shrews defenders constantly under pressure. Some great hold-up play and lay-offs. But it looked like he did lose his marker for the equaliser. Came so close to putting Town back in front but his close-range finish was blocked. Replaceed by Bonis on 70. Photo: Tina Jenner

12. Armando Dobra 5
Armando Dobra 5 On for Stirk at half-time. Almost scored a winner late on with a deflected strike. Gave away a silly free-kick at the end which led to the winner. Photo: Brian Eyre

