Goals from Bart Ogbeche and Seb Hines moved Middlesbrough up to fourth in the Championship table as Barnsley's woes on the road continued.
The home side were better throughout and were only denied a bigger scoreline by a stubborn Tykes defence.
It was an hour before Boro first broke through, with Hines heading home unmarked from a Barry Robson corner.
They made sure of the points in stoppage time when Ogbeche expertly lobbed Barnsley keeper Luke Steele.
The win means Tony Mowbray's side have now amassed 59 points from 34 games, leaving them five points off the automatic promotion places.
Barnsley, though, have now gone four away matches without earning a point and lie 16th with 43 points.
From kick-off, Boro were on the front foot with Julio Arca firing over and Lukas Jutkiewicz heading wide early on.
Soon after Jutkiewicz was in on the action again and was inches away from connecting with a Justin Hoyte cross for what would have been a certain goal.
The home attacks continued after the break and it was only a matter of time before they scored, with Hines on target.
In the final minute, Barnsley could have salvaged a point with a rare foray forward but Jason Steele dropped quickly to smother Jay McEveley's goalbound header on the line.
Two minutes into injury time, Ogbeche made sure of Boro's victory.
Middlesbrough manager Tony Mowbray:
"It was a difficult match. It's been like that for most of the season. It's torture standing there watching it and that's the Championship. No-one makes it easy for you.
"You've got to give Barnsley a lot of credit. They're a nice football team who play nice football.
"I think we're at the part of the season where we're grateful for the points. We will be better in the future."
Barnsley manager Keith Hill:
"I'm pleased with the performance, not the result. But the result wasn't decided by the opposition it was decided by individual errors by players.
"They'll be forgiven, though, because they give me everything I expect from them.
"But I can take some encouragement going into the game against Southampton [on Saturday]."
Sorry, we were unable to load match stats, please try again.