Peterborough 2-1 Barnsley
Peterborough moved out of the Championship relegation zone after Tommy Rowe scored a late winner against Barnsley.
Michael Bostwick's low free kick in the first half gave Peterborough the lead.
Marlon Harewood looked to have rescued a point with a weak 79th-minute shot from the edge of the area.
However, Rowe's drilled effort secured the three points for the home side to move them out of the bottom three and up to 21st in the table.
Barnsley, meanwhile, are bottom and four points adrift of safety.
Dwight Gayle saw a fourth minute shot denied by Barnsley keeper Luke Steele, while for the visitors Craig Davies was the first to threaten, with his shot saved by Robert Olejnik.
Peterborough took the lead just before the half hour as Joe Newell was fouled on the edge of the area and Bostwick drove the free kick inside the near post.
Barnsley improved after the break as Olejnik twice kept out efforts by Chris Dagnall, who also smashed a shot against the post.
Harewood was introduced in the 67th minute and he scored the equaliser 12 minutes later with a soft shot that crept into the net.
Peterborough were not to be denied a fourth win in five games, though, as Rowe scored from the edge of the area with three minutes remaining.
Peterborough manager Darren Ferguson said: "Getting out of the bottom three is a big psychological boost, but my main focus is always on points.
"We're up to 25 after a great run of results at a crucial time in the season but we still need eight more wins to be safe.
"That is a big ask but I've seen a hell of a lot of good things from my players lately."
Caretaker Barnsley manager David Flitcroft said: "I would have been disappointed with a 1-1 draw so I'm absolutely gutted to end up with nothing.
"The lads fought tooth and nail just as they had been doing for [former manager] Keith Hill but we just lacked that killer touch in front of goal.
"Our end product is something that has let us down all season but it is something we will continue to work on for as long as I'm here.