The hosts took a 28th-minute lead as Michael Bostwick's low free-kick found the back of the net, but Marlon Harewood deservedly equalised for the visitors with 11 minutes left, albeit in controversial circumstances.
The assistant referee had his flag up after Harewood put the ball into the net, but referee Darren Drysdale awarded the goal following a discussion with his linesman.
However, the controversy was soon forgotten as Rowe stepped up to score a dramatic late winner to secure a fourth win in five for Posh.
Peterborough had Lee Tomlin in the side after they decided to appeal his sending-off during the defeat against Bristol City on Saturday, while Barnsley caretaker boss David Flitcroft made four changes for his first game in charge, with John Stones, Martin Cranie, Tom Kennedy and Chris Dagnall handed starts.
Visiting goalkeeper Luke Steele was called into action early as he pushed away Dwight Gayle's effort in the fourth minute but neither side was able to grab a hold of proceedings.
It took until the 22nd minute for another clear opportunity and it fell to the visitors, as Robert Olejnik saved from Craig Davies.
But Posh went ahead just before the half-hour mark. Joe Newell was brought down on the edge of the area and Bostwick stepped up to drill a low effort inside the near post for his fourth goal of the season.
Darren Ferguson's hosts were on top and Gayle created an opening for himself soon after but he blazed his effort over the bar. Tomlin then unleashed a powerful hit from outside the area that Steele was unable to hold at the first attempt.
Barnsley finally came to life just before the break but Tom Kennedy's free-kick was beaten away by Olejnik.
The Tykes started strongly in the second period and Dagnall was denied by Olejnik after just 65 seconds. Dagnall then forced another save out of the Millwall goalkeeper as he beat a couple of challengers before seeing his placed finish superbly blocked.
Dagnall finally beat Olejnik in the 65th minute but his 25-yard drive bounced back off the post.
Harewood was brought on for the visitors and he grabbed the equaliser 11 minutes from time as his soft shot from the edge of the box found a way into the net, though Peterborough wanted the goal ruled out for offside.
But just as it appeared Flitcroft would earn something from his first game in charge of Barnsley, Rowe struck late on to secure the points with a drilled finish from the edge of the area.