Craig Davies's late drive gave Barnsley the win in a seven-goal thriller.
Jim O'Brien's shot took a wicked deflection off Gabriel Zakauni to put Barnsley ahead, with Jacob Butterfield's finish making it 2-0.
Ricardo Vaz Te's curling shot extended Barnsley's lead, before George Boyd slotted shot reduced the deficit.
Ryan Bennett smashed in a second for Posh and substitute Lee Frecklington made it 3-3, but Davies drilled in to seal a third successive league win.
If O'Brien, Vaz Te, Butterfield and Davies scored the goals, equally key to Barnsley's win was the goalkeeping heroics of Luke Steele.
The former Posh goalkeeper had already been tested by Grant McCann's twisting long-range drive when O'Brien's speculative strike deflected off Zakauni to wrong-foot Joe Lewis.
Steele then made a trio of stunning saves before Danny Drinkwater picked out the waiting Butterfield, who clipped the ball into the top-left corner.
Ten minutes into the second half Barnsley further extended their lead after Vaz Te curved the ball beyond Lewis' reach.
With 30 minutes remaining Posh manager Darren Ferguson made all three of his substitutions and soon after Boyd slotted home.
Frecklington then played a clever one-two with Bennett, who after taking a touch, fired a shot past Steele.
Substitute Frecklington scored the equaliser for Posh as he latched onto a clever pass from Boyd to beat Steele from 12 yards.
But with 10 minutes remaining Drinkwater jinked inside on his right foot to tee up the Davies, who drilled high into the net to seal a remarkable victory.