Cardiff’s Peter Whittingham had already hit a post when he set up Joe Ledley for his first goal of the season after just six minutes.
Ledley grabbed his second on 23 with a rare header before Jay Bothroyd’s strike (34) and Whittingham’s free-kick (38) capped an inspired and unplayable performance from City in the opening 45 minutes.
But Posh launched a stirring comeback.
Sub Josh Simpson netted from close range on 51 minutes, before Charlie Lee headed in for Posh (68).
George Boyd netted United’s third with a volley in the 89th minute and in the second minute of injury time it was Simpson who pounced from close range to grab his second and complete an amazing turnaround as Posh’s fans went wild.