Town had all the early play at the Greenhous Meadow but were stunned when Pawel Abbott brilliantly controlled a long ball from Yado Mambo to score from six yards.
Two minutes later Abbott touched in Lee Martin's centre from close range before Martin fired home a low 25-yard low drive to make it three after 32 minutes.
Shrewsbury's astonishing fightback started when Jake Robinson raced clear after 36 minutes to score his fourth goal of the season.
Mark Wright's low centre was then turned into his own net by Mambo four minutes before half-time.
Shrewsbury drew level after 61 minutes with Daniel O'Donnell's free header from Lionel Ainsworth's corner.
Sean McAllister then chased a lost cause to provide the opening for Matt Harrold to head home an unlikely winner 15 minutes from time.