Striker Barnett, a £1.1million signing from Crawley this week, headed home one minute into stoppage time to deny Rovers a precious three points in their battle to avoid the drop.
Giles Barnes' first goal for more than two years looked to have lifted Dean Saunders' side off the foot of the table.
But Posh new boy Barnett stooped to head home a cross from defender Ryan Bennett, making his last appearance before joining Norwich, to salvage a point for Darren Ferguson's side.
Rovers showed plenty of endeavour in the first half but it took them 26 minutes to register their first shot on goal, with Kyle Bennett firing straight at Posh goalkeeper Paul Jones after good work from Simon Gillett.
Posh were short of ideas going forward, with Rovers looking the more likely to open the scoring and Rovers winger Kyle Bennett turned provider for Gillett but the midfielder took too much time to get his shot in and Mark Little blocked his right-foot effort.
Posh skipper Grant McCann then breathed a sigh of relief when he slipped just inside the Rovers half and Bennett raced away and picked out striker Mamadou Bagayoko, who beat his marker with a stepover but his tame left-foot finish was saved by Jones.
It seemed the first half was destined to finish goalless but Rovers had other ideas and a minute before the break El Hadji-Diouf swung in a cross from the right and Barnes rose above his marker to head down and into the net from close range.
And Rovers almost doubled their lead nine minutes into the second half when Diouf slipped the ball invitingly into the path of Ryan Bennett and Jones produced a fine save to tip the former Bury man's measured finish around the post.
Posh boss Ferguson brought on record signing Barnett for his debut eight minutes into the second half and the visitors started to ask a few more questions of the Rovers defence, with Button palming away shots from McCann and Paul Taylor.
Barnett showed some nice touches and was denied a debut goal on the hour-mark when he rose highest to meet an inviting corner but Button tipped the ball over the crossbar.
Rovers were sitting far too deep as Posh piled on the pressure and Emile Sinclair had a good chance to equalise 12 minutes from time but the striker scuffed his shot and Button made a comfortable save.
And just when it seemed Rovers were set for a precious victory, Bennett crossed for Barnett and the big striker's header beat Button to stun Rovers.