Boro threatened to earn a point after coming back from 3-0 down to move within one goal, with Albert Adomah scoring twice in a two-minute spell.
Paddy McCourt had earlier opened the scoring for Barnsley and Jim O’Brien’s shot was then deflected in by Chris O’Grady. O’Grady quickly made it 3-0 from a penalty and the home side were cruising, but by full-time Barnsley were relieved to hear the whistle.
The Tykes opened the scoring in the 26th minute when McCourt scored his first goal for the club, walking the ball into the net after going past three defenders. He must have received a knock in the process because three minutes later he was substituted.
A minute earlier, Middlesbrough striker Lukas Jutkiewicz beat the Barnsley offside trap but blazed his shot over from 12 yards with only goalkeeper Jack Butland to beat.
Barnsley doubled their lead five minutes before the break when McCourt’s replacement O’Brien sent in a shot from the edge of the area which flicked off O’Grady and went past Middlesbrough goalkeeper Jason Steele.
There was never any doubting the scorer of the third goal after Marcus Pedersen was tripped by central defender Ben Gibson. Referee Oliver Langford pointed to the penalty spot and O’Grady beat Steele convincingly.
The Middlesbrough players were booed off the field at half-time and on their return for the start of the second half, when they replaced former Barnsley player Jacob Butterfield and Dean Whitehead with Marvin Emnes and Richard Smallwood.
In the 60th minute, Barnsley cleared a Middlesbrough corner to an unmarked Pedersen on the break but he tried to be clever when he saw goalkeeper Steele off his line and tried a long-range shot which lacked power.
Kei Kamara should have pulled one back for the visitors when he stabbed at the ball from six yards out but it hit Butland and Kamara failed to react quickly enough to take advantage.
Jutkiewicz, whose involvement faded in the second half, was replaced by Mustapha Carayol who soon curled a right-foot shot against the bar.
In the 80th minute, a header from Barnsley substitute Jason Scotland from a couple of yards out went agonisingly wide.
Middlesbrough substitute Emnes immediately went close to scoring and then a minute later the visitors managed to pull a goal back when Adomah fired in from 15 yards.
Adomah scored his second in the 84th minute with a low header from four yards to raise Middlesbrough’s hopes of a point.
Barnsley managed to hold on to their slender lead in the closing minutes, though, to earn a victory which eases the pressure on under-fire manager David Flitcroft.