Greg Halford headed the home side in front, but on-loan Scott Wootton levelled things up before Elliott Ward powered home from a corner in the last 10 minutes to hand Forest victory.
It was a quiet start with Forest skipper Chris Cohen the only man to make any inroads, although Karl Darlow was the first keeper called into action as he gathered Dwight Gayle's speculative effort.
Forest should have taken the lead as some good play down the left released Dan Harding and his cross found Radoslaw Majewski, who skied the ball over from eight yards.
But they did go ahead in the 27th minute as Greg Halford rose and got a powerful header to a Henri Lansbury corner which looked to have been cleared off the line, but the referee's assistant gave the goal. There were few complaints from the visitors.
Posh could have been level moments later as Davide Petrucci found himself in plenty of space on the edge of the box, but he snatched at his shot and sent it wide.
Billy Sharp had two chances to double the home side's lead as he first shot wide from Cohen's cross and then got a header to Simon Cox's cross, which Robert Olejnik did brilliantly to save down low.
Olejnik was called into action early in the second half as Cohen hit a long raking pass, which Cox almost got on the end of but the goalkeeper rushed out and smothered.
Cohen was again the provider moments later as his cross was met by the head of Ward, but the ball looped into the arms of Olejnik.
Darren Ferguson brought on 17-year-old Jaanai Gordon-Hutton after 57 minutes in an attempt to spur on his side, who were having plenty of possession but failing to do anything with it.
However, the equaliser came three minutes later as George Boyd's corner hit Lansbury and fell kindly for Wootton who hammered home from close range.
The home side should have taken the lead moments later as Cox played the ball across the box, but Majewski shot wide when it looked easier to score.
Seven minutes from time McLeish's men grabbed the winner as Majewski swung in a corner which Ward powered home with his head.