Two goals in five minutes dramatically turned the game in City’s favour as Lee Johnson defeated his former club to all but secure the Sky Bet Championship status of his current employers.
City twice trailed to goals from midfielder George Moncur, who had never previously scored in a Barnsley shirt, on an intense afternoon at Ashton Gate.
But Tammy Abraham and Jamie Paterson were on target with important equalisers before Aden Flint powered a header into the net 16 minutes from time to win the match.
Victory leaves City six points and nine goals clear of the relegation zone with two games to play.
Johnson kept his faith in the same starting XI who had picked up seven points from City’s last three games.
The head coach’s only alterations were to his substitutes, with Milan Djuric replacing the injured Aaron Wilbraham and Bobby Reid returning to the bench at the expense of David Cotterill.
Determined to continue their recent habit of getting on the front foot quickly, City showed plenty of early intent.
Ex-Barnsley man Josh Brownhill was cheered for a nutmeg on Gethin Jones, while Tykes defender Angus MacDonald had to slide in to dispossess Abraham when Paterson played him in.
Next it was the willing running of Matty Taylor that had the visitors worried. Latching on to a mistake by Saidy Janko, the retreating full back might have been penalised for handball in the area when Taylor attempted to lift it over his head, but referee Scott Duncan turned a blind eye.
Then Abraham’s good work down by the corner flag allowed Brownhill to find the onrushing Joe Bryan, whose driven low cross just flashed beyond the stretching in the six-yard box.
But it was not all one-way traffic. Frank Fielding was the first goalkeeper to be tested as he parried Adam Armstrong’s stinging drive, while City survived a major scare in the 20th minute when Alex Mowatt’s deflected effort had Fielding beaten but not his left-hand post, leaving the keeper counting his lucky stars when the ball rebounded off the woodwork into his arms.
By the midpoint in the first half City’s passing had gone right off the boil, with numerous players guilty of needlessly conceding possession.
When Bailey Wright was caught running towards his own goal with Marley Watkins in pursuit, the Australian waited for Fielding to come and collect the ball and was fortunate to receive a free kick for a nudge in the back.
When City did break beyond the Barnsley midfield, Marlon Pack was scythed down by Josh Scowen, who received a booking for his troubles before Pack got a restless home crowd back on City’s side with a low shot pushed aside by Adam Davies.
Two minutes later, City were behind in controversial fashion. In leaping to win a high ball in his own half, Bryan landed awkwardly and stayed down, but Barnsley continued.
Suddenly space opened up in front of Moncur, who chanced his arm from 25 yards and saw his speculative strike deflect past the stranded Fielding.
City did not know who to direct their anger at – Barnsley or the referee – before Smith lunged in on Watkins and the hostilities resumed, with the skipper yellow carded.
With three minutes of added time signalled, City finished strongly. Davies made another plunging save, this time from Taylor, before Flint improvised with an attempted overhead kick inside a crowded penalty area that sailed wide.
Johnson’s side needed to rediscover their composure and set about drawing level straight from the restart when Mark Little’s floated cross to the far post was nodded back across goal by Abraham but beyond the reach of the incoming Taylor.
Meanwhile, Barnsley had lost the services of their captain at half-time, with Marc Roberts having to be replaced by youngster Callum Evans, leaving the visitors with three 21-year-olds in their defence.
Paul Heckingbottom’s inexperienced backline was rocking when City equalised eight minutes into the second period, as Paterson’s delivery was helped back into the danger zone by Brownhill.
With Taylor and Abraham both well placed, it was the Chelsea loanee who gobbled up the chance from six yards with a typical poacher’s goal – his 26th of the season.
It should have been 27 soon after too. Again Paterson was involved, whipping in a cross from the left corner of the box and Abraham stole in front of Davies to get a toe to it, but the ball clipped the top of the crossbar on its way over from point-blank range.
Now it was all City, as Taylor’s blocked shot fell for Brownhill, who curled just over on his left foot.
But from being the dominant team, the hosts found themselves behind for a second time out of nothing as Armstrong led a quick counter-attack and fed Moncur to his right, who rifled a brilliant finish high past Fielding’s left hand from 20 yards.
This time the deficit was short-lived. Five minutes later, the momentum was back on City’s side when Paterson drifted infield and latched on to Pack’s perfectly weighted pass in behind the Barnsley defence, waited for the ball to drop and lifted it beautifully over the advancing Davies.
With 20 minutes to find a winner, City kept driving forward. Paterson fizzed a low ball across goal from which Flint was only denied by a Janko’s last-ditch block, before the big defender rose to thunder a header into the back of Davies’ net from a Paterson corner and send Ashton Gate into a frenzy.
The nature of the contest dictated the game was still not safe. When Abraham turned and looked for the bottom corner his shot struck the bottle next to Davies’ post, illustrating just how close the striker was to City’s fourth.
In the end it wouldn’t be needed, as chants of “we are staying up” reverberated around the stadium.
Even the most optimistic Blackburn Rovers supporter would struggle to disagree.