A topsy-turvy encounter saw the away side take an early lead through Jim O’Brien, before Boro responded in the second half through Mustapha Carayol and Curtis Main.
Barnsley were not to be denied, however, and Scott Golbourne equalised before Scotland sealed the points with his third goal in as many games.
After losing 4-0 at Ipswich last time out, Tony Mowbray’s side looked bereft of ideas for long spells and the visitors were good value for a sixth win in seven games.
Boro have now lost all five of their league outings in 2013, while Barnsley took another huge step forward in their battle against relegation.
Considering their current form, the last thing Boro needed was to fall behind to O’Brien’s sixth-minute strike. The Scot was fed the ball in the right channel by Chris Dagnall, and saw his speculative effort from the edge of the box take a wicked deflection off George Friend and loop over Jason Steele.
The home crowd’s frustrations were audible in the 25th minute when Nicky Bailey’s diagonal ball strayed harmlessly into touch and jeers rang out.
That anger intensified three minutes before half-time as, immediately after Emmanuel Ledesma had shot tamely at Luke Steele from 30 yards, Marlon Harewood fed O’Brien – although this time the winger’s deflected effort was claimed by Jason Steele.
Boro finally found some attacking threat from an unlikely source moments before the break; centre-back Andre Bikey galloping forward on a marauding run from his own half and unleashing a 25 yard effort that Luke Steele fumbled, only for Lukas Jutkiewicz to smash the rebound wide from six yards.
The hosts drew level in the 50th minute. Ledesma’s through-ball allowed Carayol to get the wrong side of Stephen Foster and, although Luke Steele managed to parry his initial effort, the rebound left the simplest of tap-ins for the Gambian.
Main, a half-time substitute for the ineffective Jutkiewicz, then put the Teesside outfit ahead after 62 minutes as he bundled home Seb Hines’ cross at the back post.
Having gone ahead, Middlesbrough were punished when Jason Steele fumbled a high ball into the area in the 69th minute. Tom Kennedy’s low effort across the six-yard box fell to Golbourne, who completed a simple finish to bring the Tykes level.
Five minutes later, the visitors were back in front as Jason Steele handled a backpass just outside the right-hand corner of his six-yard box, and Golbourne laid the indirect free-kick off for substitute Scotland, who rifled his effort in off the underside of the bar.
Leadbitter came closest to equalising with a fizzing 20-yard effort that Luke Steele did well to push behind to safety.
Boro’s misery was complete when referee Jeremy Simpson turned down a penalty appeal deep in stoppage time, although Main appeared to have gone down too easily.