An early goal from Jordan Rhodes put the Tykes on the back foot in the fourth minute, and when Harry Toffolo slid in to make it 2-0 just prior to the break, a night of disappointment seemed certain for the visitors.
The second half produced very little goalmouth action, but Barnsley fans had cause for some cheer late on when Callum Styles fired home probably the best goal of the match, curling a shot into the top corner with practically the last kick of the game.
Barnsley, though, remains bottom of the table with only six wins from its 43 games to date this season. With just three matches left to play, the 11 points needed to reach safety are out of reach and it will play next season in League One.
For Huddersfield, however, things are much brighter, with Saturday's (AEST) result confirming its place in the play-offs for the Premier League.
The Terriers are currently in third place on the table, just one point outside the top two automatic promotion places. Fulham, in top spot, has already confirmed it will play in the Premier League next season, and while second-placed Bournemouth has three games in hand, the second automatic spot remains a slim possibility for Huddersfield.