Middlesbrough substitute Ishmael Miller came off the bench to snatch the winner and deny rock-bottom Peterborough their first point from a losing position this season.
Faris Haroun returned from the calf injury which had kept him out of Boro’s last four fixtures and soon made up for lost time with a first-half brace.
His first goal came after nine minutes when he provided a cool finish to a blistering counter-attack which left Posh stunned.
Any home supporters privy to the knowledge Peterborough had not taken a single point after going behind would not have been surprised to see Haroun head home the second shortly afterwards.
However, Peterborough staged an unlikely comeback when on-loan striker Dwight Gayle struck either side of half-time to turn the game on its head.
Both sides pushed hard for a winner but Miller’s speculative effort surprised Posh stopper Robert Olejnik to extend Darren Ferguson’s side’s winless run to eight games.
Peterborough could scarcely have imagined how their first spell of sustained pressure would end as Middlesbrough executed a devastating counter-attack to break the deadlock.
Scott McDonald dispatched a diagonal ball right into Haroun’s path and the Belgian midfielder strode forward with purpose before slotting past Olejnik.
Their wait for that second goal did not last long as Haroun made it 2-0 inside 20 minutes.
Stuart Parnaby delivered from the right and Haroun proved he was the hungriest man inside the box by running across his marker to meet the cross and nod home.
Tommy Rowe snatched at a chance as Peterborough looked to get themselves back in the contest, but Boro were looking comfortable until Gayle’s thumping finish seven minutes prior to the break.
The striker, who grabbed the first goal of his loan spell from Dagenham last week against Blackpool, feigned one way then shuffled the ball on to his right foot before rifling into the top corner.
Gayle’s moment of magic rocked Tony Mowbray’s men and Peterborough almost reached half-time all square but George Thorne’s sweetly-struck strike fell narrowly wide.
The London Road faithful were taking a shine to Gayle’s work ethic and he endeared himself to them even more with the leveller seven minutes into the second period.
The 22-year-old won the corner himself, drawing Jason Steele into a smart stop from a tight angle, before he prodded home Lee Tomlin’s set-piece delivery.
Gayle was inspiring those around him too and a break similar to the one which led to Boro’s opener almost nudged the hosts in front for the first time.
Tomlin released the overlapping Rowe and his drilled effort just missed the target.
Gayle just missed out on an inviting cross in his quest for a hat-trick but it was the visitors who were to provide the killer blow 14 minutes from time.
Miller, who had been on the pitch for only three minutes, tried his luck from the edge of the penalty area and Olejnik was beaten by a shot which lacked any great deal of power or pace.