Aaron Mclean grabbed a late winner as Peterborough claimed a third consecutive League Two victory.
Posh dominated the first half and Craig Mackail-Smith hit the post.
The home side took the lead after the break when George Boyd fired in after Adam Newton's fine run but Matt Bloomfield levelled with a low drive.
Russell Martin also rattled the home bar with a free-kick but Posh won it when McLean showed great strength to head home Chris Whelpdale's long throw.