The Tykes stormed into a 2-0 lead by half-time at London Road thanks to goals from Jim O’Brien and Jacob Butterfield, and the heroics of Luke Steele in the visiting goal.
Ricardo Vaz Te added a third after the break but Peterborough raced back to equalise with strikes from George Boyd, Ryan Bennett and substitute Lee Frecklington.
But Davies condemned the Posh to a seventh defeat in their last eight league games with an unstoppable drive 10 minutes from time as the Tykes secured a third straight Championship win.
Steele had no respite throughout the first period, being summoned to catch Grant McCann’s twisting long-range drive and watching Boyd’s audacious strike sail just wide of goal in the first 10 minutes.
Lee Tomlin tested the former Manchester United stopper once more before the Tykes made an unlikely breakthrough in the 17th minute.
There was a touch of fortune about Jim O’Brien’s first goal of the season. The Scottish midfielder dug out a speculative strike that took a wicked deflection off Posh defender Gabriel Zakauni, wrong-footed Joe Lewis and bounced into the home net.
McCann looked most likely to even up the scores, this time forcing Steele to tip a stinging effort around his post.
Boyd appeared in a good position once more on the half-hour mark, his snap-shot parried to safety by the under-siege Steele.
And a trio of stunning saves was complete with 38 minutes played as the 27-year-old goalkeeper confidently plucked a Bennett header out of the area.
If the home side thought they had thwarted the Tykes’ determination to grab all three points at London Road, they were proved wrong on the cusp of half-time.
Danny Drinkwater sent a slide-rule pass across the penalty box for the waiting Butterfield to clip the ball into the top-left corner with consummate ease.
Darren Ferguson’s charges may have received forceful words of encouragement from their boss at the interval, but it was not immediately in evidence as Barnsley made it three in the 55th minute.
Unopposed, Jay McEveley galloped forward, his pass finding the onrushing Vaz Te, who connected with the ball perfectly to curve gracefully beyond Lewis’ reach.
Perhaps out of sheer panic, Ferguson opted to make all three of his substitutions at once with 30 minutes remaining.
Stephen Foster cleared a Frecklington corner as far as the lurking Tomlin, who picked out Boyd unmarked in the penalty box. The playmaker finally broke Steele’s resolve by picking out the near corner and slotting home.
Their thirst for goals restored, Peterborough narrowed the deficit to a single goal in the 68th minute.
Frecklington, who had terrorised the Barnsley flanks since his introduction on the hour mark, played a clever one-two with Bennett, the latter taking a fine touch and smashing past the flailing Steele.
And to the horror of the travelling faithful, Frecklington turned scorer two minutes late, latching onto a clever pass from Boyd to gleefully beat Steele from 12 yards.
But the story was not yet written as Davies produced the late twist.
Drinkwater, the engineer of much of the Tykes’ creativity in the first half, jinked inside on his right foot to tee up the ex-Chesterfield man, who drilled high into the net to seal victory.