Ryan Williams came off the bench to net a dramatic 90th-minute winner with his first touch in a seven-goal thriller against Cardiff.
First-half goals from Sam Winnall and Josh Scowen cancelled out Sean Morrison's early header to give the Tykes a two-goal advantage over the home side at the break.
Strikes from Peter Whittingham and Anthony Pilkington in the space of 10 minutes looked to have rescued Cardiff.
But Williams' late winner snatched the three points to give the Tykes their fourth win in 15 games.
But Barnsley boss Paul Heckingbottom is refusing to set a target for his players this season.
Heckingbottom said: "We don't set aims, if you set a goal you're limiting yourself and we just want to win as many games as we can.
"It's reflected in games like that. We've got a group of players who have responded to that over the past year or so. We know we won't win them all, but we'll try.
"I've had some big games in the short time I've been doing it. But in terms of the scoreline and nature of the game, it's probably the most dramatic game I've been involved in.
"It will be a good one for the fans to watch back, maybe not for us coaches."
Cardiff got off to the perfect start when an unmarked Morrison headed home Whittingham's corner with ease in the third minute.
Such poor defending was surprising to see from a Barnsley defence who had previously kept three clean sheets in their last four away games.
The Tykes equalised in the 19th minute through top scorer Winnall after Conor Hourihane's cross found the Barnsley striker whose header looped over a helpless Ben Amos.
Hourihane leads the Championship charts with nine assists this season and put on another fine performance.
Cardiff should have retaken the lead when Junior Hoilett found himself one-on-one with Adam Davies, but the Canada international skewed his shot wide.
Hoilett was involved again shortly after as he played in Kenneth Zohore whose shot was saved by Davies. The resulting corner saw the Barnsley goalkeeper save Bruno Magna's goal-bound header.
Neil Warnock's men would rue those chances as Barnsley went in front in the 32nd minute following a clinical counter-attacking move.
A Cardiff corner was cleared and Ryan Kent sprinted down the left wing to cross to Sam Morsy whose superb lay-off allowed Winnall to slot the ball past Amos for his ninth goal of the season.
Barnsley extended their lead two minutes from the break thanks to a second Amos goalkeeping error in as many games.
Amos rushed off his line to try and beat Kent to Hourihane's defence-splitting pass, but the Liverpool loanee won the race and squared the ball to Scowen who had a simple tap-in.
The former Bolton keeper was also at fault for Wolves' goal in the Bluebirds' 2-1 win on Tuesday.
Cardiff started the second-half with intent as Hoilett hit the post from close-range.
The home side pulled a goal back with 11 minutes to go through Whittingham after his deflected shot beat Davies.
The dramatic equaliser came in the 89th minute after Pilkington poked the ball home following Morrison's knock-down from a corner.
But two Barnsley substitutes combined well as Marley Watkins' cut-back was met by Williams who scored with his first touch in injury-time.
Get more from the Yorkshire Post Sports team
Like the Yorkshire Post Facebook Football page
Follow the Yorkshire Post's new Instagram account - @ypsport
Get the latest news by liking our Twitter account: @YPSport