Two headers from corners gave Cardiff City their first away win in four attempts and took them back to the top of the Championship table.
Teenage defender Ben Nugent marked his first league start with a goal after dispatching Peter Whittingham's corner.
Aron Gunnarsson was then left unmarked at the far post to convert from another Whittingham delivery after the break.
A sweet finish from Jacob Mellis gave Barnsley hope, but Cardiff held on despite Simon Lappin's late red card.
The left-back's dismissal for a second yellow card two minutes before time led to a frantic finish as Cardiff survived two penalty claims and needed two fine interventions from goalkeeper David Marshall.
But time came to their rescue, and left Barnsley to contemplate a fifth defeat in seven games, leaving them one point above the relegation places.
Cardiff end away blues
- Before beating Barnsley, Cardiff had not won a match while wearing blue this season
- The Bluebirds controversially changed from blue to red as their primary colour at the start of the season and have won all nine home games in red
For the 12th time in 18 Championship games this season, Cardiff took the lead.
Nugent wrestled free from his marker and used his 6ft 4in stature to good effect to reach Whittingham's hanging delivery.
The 19-year-old's textbook downward header skipped off the surface past home goalkeeper Luke Steele.
The visitors were twice let off the hook in the first half by poor Barnsley finishing.
Stephen Dawson sliced his volley wide after Cardiff debutant Lappin, on loan from Norwich City, was caught out of position.
And then on the stroke of halftime, unmarked Marcus Tudgay headed weakly wide from a few yards out.
Cardiff were guilty of a glaring miss of their own minutes after the break when Heidar Helguson hit a tame shot from 12 yards, which was turned away by Steele.
But Helguson's blushed were spared by fellow Icelander Gunnarsson as the midfielder headed in at the far post from the resulting corner.
The introduction of Reuben Noble-Lazarus and Akos Buzsaky gave Barnsley much needed-impetus and they capitalised on a purple patch to pull a goal back.
Mellis showed his team-mates how to finish by composing himself and squeezing the ball inside the far post.
Lappin's debut turned sour when he was shown a second yellow card, giving the home side plenty of encouragement to launch a late salvo but they failed to find the telling blow to salvage a point.
Barnsley manager Keith Hill said: "We have let Luke Steele down.
"He has made two match-winning saves and we conceded from both corners and the players are responsible for the individual mistakes they have made.
"The individual errors cost you and that is the difference between the cream and the elite and us at this moment in time."
Cardiff City manager Malky Mackay said: "It was just good to have another three points, coming to a tough ground.
"We were playing against a team that has a fresh influx of players through the week, so we always knew it was going to be difficult.
"I am delighted to come away from here having been clinical and getting the three points.
"We were quite comfortable and in the second half we started really well and on another day could have had another two or three goals had we picked them off on the counter attack."
- 01 Steele
- 03 Golbourne
- 14 Wiseman
- 15 McNulty
- 25 Cranie
- 07 Dawson (Buzsaky - 57' Booked )
- 10 Done (Noble-Lazarus - 57' )
- 21 Mellis Booked
- 28 Greening
- 09 Davies
- 29 Tudgay (Sinclair - 81' )
- 30 Lidakevicius
- 06 Foster
- 34 Stones
- 08 O'Brien
- 36 Buzsaky
- 24 Noble-Lazarus
- 27 Sinclair
- 01 Marshall Booked
- 05 Hudson
- 12 Connolly
- 31 Nugent
- 07 Whittingham
- 13 Kim Bo-Kyung
- 16 Noone
- 17 Gunnarsson (Mutch - 70' Booked )
- 24 Lappin Dismissed after an earlier booking
- 20 Mason (Bellamy - 75' )
- 22 Helguson (Gestede - 61' )
- 32 Lewis
- 11 Conway
- 18 Mutch
- 21 Ralls
- 42 John
- 15 Gestede
- 39 Bellamy
Live Text Commentary
Full Time The referee ends the match.90:00 +4:26
Short corner taken by Peter Whittingham.90:00 +4:03
Corner taken short by Peter Whittingham.90:00 +3:16
Free kick taken by Craig Noone.90:00 +3:16 Booking
Booking Jacob Mellis is shown a yellow card.90:00 +3:09
Jacob Mellis gives away a free kick for an unfair challenge on Craig Noone.90:00 +0:34
Craig Bellamy fouled by Jonathan Greening, the ref awards a free kick. David Marshall takes the free kick.88:50
Free kick crossed right-footed by Akos Buzsaky from right wing, Mark Hudson manages to make a clearance. Akos Buzsaky decides to take a short corner.88:50 Dismissal
Dismissal Simon Lappin receives a red card.88:37
Foul by Simon Lappin on Reuben Noble-Lazarus, free kick awarded.88:15 Booking
Booking David Marshall goes into the referee's book for time wasting.87:11
Drilled right-footed shot by Jacob Mellis. Blocked by Mark Hudson. Corner from the left by-line taken by Akos Buzsaky, save by David Marshall.84:41
Direct free kick taken by David Marshall.84:41 Booking
Booking Akos Buzsaky is shown a yellow card.84:22
Free kick awarded for an unfair challenge on Craig Noone by Akos Buzsaky.83:18
Jonathan Greening restarts play with the free kick.83:18 Booking
Booking Jordon Mutch shown a yellow card.83:04
Free kick awarded for a foul by Jordon Mutch on Craig Davies.82:26
Reuben Noble-Lazarus has an effort at goal. Save by David Marshall.80:05 Substitution
Substitution (Barnsley) makes a substitution, with Emile Sinclair coming on for Marcus Tudgay.
Effort on goal by Craig Davies from outside the box goes harmlessly over the bar.79:31
Akos Buzsaky takes the inswinging corner, Mark Hudson manages to make a clearance.78:05
Effort on goal by Bo-Kyung Kim from outside the area goes harmlessly over the bar.75:35
The assist for the goal came from Scott Wiseman.75:35 Goal scored
Goal! - Jacob Mellis - Barnsley 1 - 2 Cardiff A goal is scored by Jacob Mellis from just inside the penalty area to the bottom right corner of the goal. Barnsley 1-2 Cardiff.74:02 Substitution
Substitution Craig Bellamy is brought on as a substitute for Joe Mason.73:17
Effort from the edge of the area by Bo-Kyung Kim goes wide of the left-hand upright.71:59
Unfair challenge on Marcus Tudgay by Ben Nugent results in a free kick. Jonathan Greening delivers the ball, Header from deep inside the penalty area by Marcus Tudgay goes harmlessly over the crossbar.69:25 Substitution
Substitution (Cardiff) makes a substitution, with Jordon Mutch coming on for Aron Gunnarsson.67:17
Drilled right-footed shot by Rudy Gestede. Luke Steele makes a save. Bo-Kyung Kim has an effort at goal from just inside the box that misses to the right of the goal.65:58
Akos Buzsaky has an effort at goal. David Marshall makes a save.63:47
Shot from 30 yards by Jacob Mellis. Save by David Marshall.59:36 Substitution
Substitution Rudy Gestede joins the action as a substitute, replacing Heidar Helguson.59:36
The offside flag is raised against Craig Davies. David Marshall takes the indirect free kick.59:13
Unfair challenge on Marcus Tudgay by Mark Hudson results in a free kick. Akos Buzsaky restarts play with the free kick.58:14
Peter Whittingham takes the outswinging corner, Unfair challenge on Jimmy McNulty by Matthew Connolly results in a free kick. Luke Steele restarts play with the free kick.57:46
Scott Wiseman challenges Bo-Kyung Kim unfairly and gives away a free kick. Peter Whittingham restarts play with the free kick.55:44 Substitution
Substitution (Barnsley) makes a substitution, with Reuben Noble-Lazarus coming on for Matty Done.55:44 Substitution
Substitution (Barnsley) makes a substitution, with Akos Buzsaky coming on for Stephen Dawson.55:44
Aron Gunnarsson produces a right-footed effort from long distance that goes harmlessly over the bar.53:04
Simon Lappin produces a cross, Header on goal by Heidar Helguson from inside the box goes harmlessly over the target.50:26
Assist by Peter Whittingham.50:26 Goal scored
Goal! - Aron Gunnarsson - Barnsley 0 - 2 Cardiff Aron Gunnarsson fires in a goal from close in to the bottom left corner of the goal. Barnsley 0-2 Cardiff.49:39
Heidar Helguson takes a shot from 6 yards. Luke Steele makes a brilliant save. Peter Whittingham takes the inswinging corner,47:33
Jacob Mellis takes the chance to get an effort at goal. Save by David Marshall. Inswinging corner taken right-footed by Jonathan Greening played to the near post, Matthew Connolly makes a clearance.46:50
Matty Done challenges Bo-Kyung Kim unfairly and gives away a free kick. Simon Lappin takes the free kick.46:11
Jonathan Greening challenges Heidar Helguson unfairly and gives away a free kick. Mark Hudson takes the direct free kick.45:01
The referee gets the second half started.45:00 +1:38 Half time
Half Time The referee calls an end to the first half.45:00 +0:19
Matty Done fouled by Simon Lappin, the ref awards a free kick. Matty Done produces a cross, Marcus Tudgay produces a header from close range which goes wide of the left-hand upright.44:18
Corner taken right-footed by Jonathan Greening, Foul by Jimmy McNulty on Ben Nugent, free kick awarded. Free kick taken by David Marshall.43:38
Craig Davies has an effort at goal from 20 yards. Save by David Marshall. Corner from the right by-line taken by Matty Done, clearance by Heidar Helguson.37:39
The ball is swung over by Scott Wiseman, clearance by Matthew Connolly. Corner taken by Jonathan Greening from the right by-line to the near post, Marcus Tudgay produces a header from deep inside the six-yard box that clears the crossbar.36:14
Unfair challenge on Craig Davies by Craig Noone results in a free kick. Jonathan Greening delivers the ball from the free kick right-footed from left wing, Matthew Connolly makes a clearance.35:31
The official flags Marcus Tudgay offside. Indirect free kick taken by David Marshall.33:14
Inswinging corner taken left-footed by Peter Whittingham played to the near post, clearance by Marcus Tudgay. Inswinging corner taken left-footed by Peter Whittingham from the right by-line to the near post, clearance made by Craig Davies.32:02
Free kick awarded for a foul by Jonathan Greening on Aron Gunnarsson. Free kick taken by Ben Nugent.28:52
Effort on goal by Stephen Dawson from inside the box misses to the right of the target.26:35
Free kick awarded for an unfair challenge on Craig Davies by Ben Nugent. Shot comes in from Craig Davies from the free kick. Corner taken by Jonathan Greening from the right by-line played to the near post, clearance by Ben Nugent.25:08
Free kick taken by Jimmy McNulty.25:08 Booking
Booking Simon Lappin goes into the book.24:57
Free kick awarded for a foul by Simon Lappin on Jonathan Greening.24:39
Joe Mason concedes a free kick for a foul on Scott Golbourne. Free kick taken by Jimmy McNulty.21:05
Assist on the goal came from Peter Whittingham.21:05 Goal scored
Goal! - Ben Nugent - Barnsley 0 - 1 Cardiff Ben Nugent finds the back of the net with a headed goal from deep inside the penalty area. Barnsley 0-1 Cardiff.20:15
Joe Mason takes a shot. Save by Luke Steele. Corner taken left-footed by Peter Whittingham from the left by-line,19:02
Craig Noone has an effort at goal from outside the penalty box missing to the wide right of the goal.17:36
Craig Davies concedes a free kick for a foul on Mark Hudson. Free kick taken by David Marshall.13:44
Shot from 25 yards by Joe Mason. Save made by Luke Steele.9:20
Jimmy McNulty gives away a free kick for an unfair challenge on Joe Mason. Peter Whittingham delivers the ball from the free kick left-footed from right wing, save made by Luke Steele.7:31
Foul by Craig Noone on Craig Davies, free kick awarded. Direct free kick taken by Scott Golbourne.5:57
Jacob Mellis concedes a free kick for a foul on Craig Noone. Strike comes in from Peter Whittingham from the free kick.5:40
Unfair challenge on Heidar Helguson by Martin Cranie results in a free kick. Peter Whittingham takes the free kick.4:58
Effort on goal by Craig Davies from just inside the area clears the bar.2:47
Jonathan Greening produces a right-footed shot from outside the penalty box and misses right.0:35
Jonathan Greening gives away a free kick for an unfair challenge on Craig Noone. Free kick crossed right-footed by Peter Whittingham from right wing, clearance by Scott Wiseman. Outswinging corner taken left-footed by Peter Whittingham from the left by-line, clearance by Marcus Tudgay.0:00
The ref blows the whistle to start the match.
Live data and text provided by our data suppliers