Adam Armstrong put the Tykes ahead as Conor Hourihane's free-kick was nodded down by Marley Watkins and fired in.
Scott Hogan had a fine chance to level as he got in behind the visitors' defence, but Adam Davies was quick off his line to deny the Brentford forward his ninth goal of the season.
The win was sealed when Ryan Kent hit the post and Sam Winnall pounced.
Late on, Davies again had to make a fantastic save as Josh Clarke rushed through on goal, as the Tykes' keeper forced him wide and then got down low to block.
Earlier, Watkins whipped a dangerous cross into the Bees' box, but Winnall could only head straight at home keeper Daniel Bentley.
The Bees suffered their fifth loss of the season and are winless in their last four, only picking up two points during this period.
Barnsley's sixth win of the season ends a run of three defeats for the visitors, and is their first victory since beating Wolves 4-0 at Molineux on 13 September.
Brentford manager Dean Smith:
"We controlled the first half without creating too many chances. There were half-chances for both sides but we gave them a hand.
"Our decision-making was poor on the ball. We had three or four opportunities to play Scott Hogan in but we took an extra touch which slowed play down for us.
"When you are two goals up you can afford to take a few chances and you will look sharper, but if we'd taken our chances it might have been a different story.
"There is an expectancy for us to beat Barnsley and people fancy us to beat them, but every game is different and there are no easy ones."
Barnsley manager Paul Heckingbottom:
"I'm really pleased. It's what we've been after for a few games now, where we've performed well and not got our rewards.
"There were fewer errors and the decision-making was much better. It's been easy to see what the problem has been because the eight goals we've conceded have been down to us and things we did wrong.
"We put that right today and got what we deserved. We have to bring the same level of performance we've shown today into every game."
"Brentford have only conceded two at home this season and are a good side, good with the ball and tough to handle, but we came with a game plan and executed it. We deserved the win."
Match ends, Brentford 0, Barnsley 2.
Second Half ends, Brentford 0, Barnsley 2.
Attempt saved. Conor Hourihane (Barnsley) left footed shot from outside the box is saved in the top left corner. Assisted by Marley Watkins.
Corner,  Brentford. Conceded by Adam Davies.
Attempt saved. Nico Yennaris (Brentford) right footed shot from the centre of the box is saved in the top right corner. Assisted by Maxime Colin.
Foul by Nico Yennaris (Brentford).
Ryan Williams (Barnsley) wins a free kick in the defensive half.
Substitution, Barnsley. Jacob Brown replaces Sam Winnall.
Offside, Barnsley. Adam Davies tries a through ball, but Sam Winnall is caught offside.
Corner,  Brentford. Conceded by Adam Hammill.
Ryan Woods (Brentford) wins a free kick on the right wing.
Foul by Adam Hammill (Barnsley).
Attempt missed. Scott Hogan (Brentford) right footed shot from the right side of the box is close, but misses to the left. Assisted by Josh Clarke.
Josh Clarke (Brentford) wins a free kick on the right wing.
Foul by Sam Morsy (Barnsley).
Substitution, Barnsley. Adam Hammill replaces Ryan Kent.
Josh Clarke (Brentford) wins a free kick in the defensive half.
Foul by Sam Morsy (Barnsley).
Substitution, Barnsley. Ryan Williams replaces Adam Armstrong.
Conor Hourihane (Barnsley) is shown the yellow card for a bad foul.
Yoann Barbet (Brentford) wins a free kick in the attacking half.
Foul by Conor Hourihane (Barnsley).
Attempt blocked. Philipp Hofmann (Brentford) left footed shot from the centre of the box is blocked. Assisted by Josh Clarke.
Substitution, Brentford. Philipp Hofmann replaces Romaine Sawyers.
Corner,  Barnsley. Conceded by John Egan.
Foul by Scott Hogan (Brentford).
Adam Davies (Barnsley) wins a free kick in the defensive half.
Corner,  Brentford. Conceded by Adam Davies.
Attempt saved. Josh Clarke (Brentford) right footed shot from the right side of the box is saved in the bottom right corner.
Attempt blocked. Josh Clarke (Brentford) right footed shot from outside the box is blocked. Assisted by Josh McEachran.
Attempt blocked. Adam Armstrong (Barnsley) right footed shot from the centre of the box is blocked. Assisted by Ryan Kent.
John Egan (Brentford) wins a free kick in the defensive half.
Foul by Sam Winnall (Barnsley).
Maxime Colin (Brentford) hits the bar with a right footed shot from the right side of the box.
Delay over. They are ready to continue.
Delay in match Marley Watkins (Barnsley) because of an injury.
Attempt missed. Josh McEachran (Brentford) left footed shot from outside the box is close, but misses to the right. Assisted by Maxime Colin.
Attempt missed. Conor Hourihane (Barnsley) left footed shot from outside the box is close, but misses to the right.
Goal!  Brentford 0, Barnsley 2. Sam Winnall (Barnsley) left footed shot from very close range to the centre of the goal.
Ryan Kent (Barnsley) hits the left post with a left footed shot from the left side of the box. Assisted by Adam Armstrong.
Barnsley's first win in eight matches condemned Brentford to defeat in their 4,000th league game.