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.
Manager Tony Mowbray had called for his team to go back to basics in his programme notes after the 4-0 trouncing at Ipswich - but his side looked bereft of ideas for long spells in front of a disgruntled crowd at the Riverside Stadium 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, and will need to regather quickly to prevent their promotion challenge ebbing away, 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.
That should have sparked the home side into life, but their efforts to get back into the game were thwarted by numerous wayward passes and a chronic lack of creativity in the final third.
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.
The home goalkeeper had to have his wits about him moments later to parry former West Ham forward Harewood's powerful 20-yard volley behind for a corner.
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' first-half woes looked like continuing after the break when Grant Leadbitter wasted a free-kick in a good position by overhitting his cross out for a goal-kick, but they 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.
Barnsley nearly regained their advantage a minute later when Harewood drilled a 20-yard effort just wide of Jason Steele's near post.
The home side grew in confidence after their first goal in 230 minutes of Championship football, with Ledesma almost freeing Leadbitter on the hour mark.
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.
- Sports & Recreation
- Luke Steele
- Scott Golbourne