The visiting Bluebirds took the lead in the fifth minute when Don Cowie scored from just inside the penalty area.
After the break both sides had chances to grab the fourth goal of the match.
When it arrived it went the way of the visitors and Peter Whittingham, who curled in a direct free kick from 25 yards out.
With the game looking as if it was heading for a draw, Gunnarsson appeared inside the six-yard box to turn Andrew Taylor's cross past Paul Jones in the Posh goal.
However, Gunnarsson's intervention would not prove to be a match-winning one, as McCann kept his cool from the penalty sport to bring his side back level.
Just when Cardiff had settled for the point, Posh substitute Paul Taylor broke free of the Bluebirds' defence and shot low past David Marshall to hand his side all three points in stoppage time.