The impressive Reds upset Neil Warnock’s Cardiff as sub Ryan Williams grabbed a dramatic 95th-minute winner in South Wales.
Williams pounced deep into added time to stun Cardiff, who had fought back from 3-1 down with 10 minutes to go to equalise.
It wasan end-to-end start to the game, though it was the hosts who struck after just three minutes.
It was a disappointing goal to concede from the Reds’ point of view, with Sean Morrison rising comfortably to head home from Peter Whittingham’s corner-kick.
It was an early blow for the visitors, but they responded well.
Defender Angus MacDonald volleyed narrowly wide, while Sam Morsy cracked in a shot which Ben Amos saved superbly.
The Reds grabbed themselves an equaliser after 19 minutes, with skipper Conor Hourihane once again the architect as his pinpoint cross was headed home clinically by Sam Winnall.
Junior Hoilett went close as the hosts hit back immediately, only for Winnall to do the business again for the Reds just past the half-hour mark.
This time the Barnsley hit-man fired clinically past Amos after meeting a neat lay-off from Morsy.
Incredibly it was 3-1 just before the break. The rampant Reds stormed further clear as Josh Scowen finished off a smart through-ball from youngster Ryan Kent.
The visitors looked to be in cruise control, though seconds into the second period Hoilett cracked an effort against the post for Cardiff.
The end-to-end theme then continued as Reds striker Tom Bradshaw smashed a shot into the side-netting.
Whittingham lashed home to make it 3-2 with 11 minutes to go - via a deflection off Marc Roberts - before the Cardiff City Stadium erupted when Pilkington lashed home past Davies just as the game was about to enter stoppage-time.
However, sub Williams struck deep into the added time to hand the Reds a dream win.
Cardiff (4-4-2): Amos; Peltier, Manga, Connolly, Morrison; Noone (Harris, 63), Gunnarsson, Hoilett (Lambert, 75), Whittingham; Pilkington, Zohore. Subs not used: Wilson, Bennett, Ralls, Immers, O’Keefe.
Barnsley (4-4-2): Davies; Bree, MacDonald, Roberts, Yiadom; Morsy, Scowen, Hourihane, Kent (Watkins, 77); Winnall, Bradshaw (Williams, 90). Subs not used: Townsend, Kpekawa, Evans, Jackson, Payne.
Referee: Tony Harrington (Cleveland).