The hosts had won all 10 of their previous home league games this season, but goals from Michael Bostwick and Dwight Gayle gave Posh a surprise 2-0 lead.
Rudy Gestede grabbed a goal back for the Bluebirds late on, but the visitors were able to hold out for their first win since October 27, much to the delight of their manager.
He said: "We have beaten the best team in the league so that shows we can beat any team in this league.
"It's a very good day. I have always believed in the players and maintained the confidence that we can get the job done.
"We stuck to the game plan and deserved the win but we didn't finish them off. We were hanging on a bit at the end. But if we continue to perform like that we will be fine in this league."