A tight and scrappy game at Oakwell was settled by a moment of rare quality in the second half when Andrew Taylor's delightful cross was coolly guided home by the head of Liam Lawrence.
It stretched their unbeaten run to seven games and moves them two points off seventh-placed Middlesbrough with three games to go.
For Barnsley, who had plenty of possession but created very little, the season cannot end quickly enough as a capitulation in the second half of the season has seen them win just one of their last 12 and they are only eight points above the drop zone.
Malky Mackay arrived in South Yorkshire looking to strengthen their grip on a top six place and made two changes with Joe Mason and Lawrence coming into the side while Barnsley made one change with Nathan Doyle replacing Rob Edwards.
It was an inauspicious start with neither side able to hit their straps in the final third and as a result there was little in the way of clear-cut chances in the opening 25 minutes.
Kenny Miller scuffed a shot that David Button had no problem in saving while Barnsley loanee Michael Tonge dragged a 20-yard effort wide.
Barnsley were beginning to look the more likely and Frank Nouble tested David Marshall in the visitors' goal for the first time when he escaped down the left, but his effort was easily snaffled by Marshall.
But they could not sustain their pressure and Aron Gunnarsson stung the palms of Button with a low drive and Peter Whittingham curled a free-kick just wide as Cardiff finished a first half to forget the strongest.
Both sides created chances in the opening exchanges of the second period which defied the drab nature of the preceding 45 minutes.
Cardiff's first opening came within 30 seconds of the restart when Don Cowie exchanged passes with Miller but his left-footed effort was no concern for Button before Nouble then headed over a Jim O'Brien cross for the hosts from eight yards out.
Unfortunately, the game slipped into its old ways and despite a spell of concerted Barnsley pressure, their final pass let them down and they failed to test Marshall.
And Cardiff made them pay the ultimate price as they took the lead in the 69th minute with a fine goal.
Left-back Taylor advanced down the left and delivered an inviting cross for Lawrence to nod back across goal and into the bottom corner.
Ben Turner somehow poked over from close range as the Bluebirds continued to press, but they saw out the remaining time with ease.