Match ends, Derby County 2, Barnsley 1.
Derby scored twice in the first half to leave Barnsley four points adrift of safety in the Championship.
Jeff Hendrick netted the opener for the home side, letting fly from long-range after Craig Bryson's pass.
They grabbed their second just before the interval through Johnny Russell, whose looping shot evaded Luke Steele.
Barnsley pulled a goal back with 10 minutes remaining when Nick Proschwitz scored from inside the box, before Steele saved Russell's spot-kick.
The hosts started the match on the front foot and Hendrick curled a shot just over the bar in the opening 10 minutes, but former Rams player Tomasz Cywka forced Lee Grant into a save in the 17th minute in a rare Barnsley attack.
Hendrick, though, gave Steve McClaren's men the lead on 34 minutes, as goalkeeper Steele thought a 25-yard shot from Hendrick was going wide only for the ball to creep inside his right post.
Steele was blameless for the second goal in the 42nd minute when Russell's 22-yard strike took a deflection off team-mate Craig Bryson and looped inside the net.
The visitors started the second half encouragingly. Tom Kennedy's 20-yard free-kick was touched over the crossbar by goalkeeper Grant.
Bryson curled a 20-yard free-kick narrowly over for Derby, before Craig Forsyth's header was cleared off the line.
But Barnsley were back in it with 10 minutes to go when Lewin Nyatanga played the ball in for Proschwitz to slide home.
Steele kept his side in it two minutes later when he saved a Russell penalty after Conor Sammon had been tripped by Jean Yves Mvoto but they remain in trouble with just two games remaining.
Derby head coach Steve McClaren: "The last 10 minutes were very unnecessary and shows we still have a bit to do with this team.
"When we control a game like that, play the football we do and create the chances we do, we need to be more ruthless and it nearly cost us in the end. So what could have been a harsh lesson was in the end just a lesson that we need to carry forward and take into the play-offs.
"To create that many chances and only score two was unbelievable. I couldn't fault the performance and the attitude, the only thing I could fault was we didn't get the third goal.
"When you are on top and you've got them down, you have to make sure you finish them. But we didn't, we let them back up and gave them a chance, and against different opponents that might have cost us."
Barnsley manager Danny Wilson: "It doesn't really change anything, we've always needed to win games and the next two games we've got to win.
"It's as simple as that. Everyone will be writing us off, we are down in everybody's eyes and that's understandable. But we have six valuable points to play for and who knows what twist of fate is waiting on the last day of the season?
"We have to genuinely believe we can be the recipient of a good result on that particular weekend and stay up, but it will need two wins. You know from experience that on the last day of the season peculiar things happen.
"We've had some very good displays in recent weeks and that gives me belief, it really does. And we have some very good characters in the dressing room who will give it everything."
- 34ThorneSubstituted forEustaceat 63'minutes
- 9MartinSubstituted forSammonat 79'minutes
- 10WardSubstituted forDawkinsat 66'minutes
- 8DawsonBooked at 58mins
- 42McCourtSubstituted forMellisat 45'minutes
- 14LawrenceBooked at 60minsSubstituted forProschwitzat 72'minutes
- 19CywkaSubstituted forNoble-Lazarusat 68'minutes
- Graham Scott
- Shots on Target
Second Half ends, Derby County 2, Barnsley 1.
Attempt blocked. Simon Dawkins (Derby County) right footed shot from the left side of the box is blocked. Assisted by Conor Sammon.
Attempt missed. Nick Proschwitz (Barnsley) right footed shot from outside the box is too high from a direct free kick.
Hand ball by John Eustace (Derby County).
Attempt saved. Craig Bryson (Derby County) right footed shot from the centre of the box is saved in the bottom right corner. Assisted by Conor Sammon with a headed pass.
Attempt saved. Dale Jennings (Barnsley) right footed shot from long range on the left is saved in the top centre of the goal. Assisted by Lewin Nyatanga.
Offside, Barnsley. Lewin Nyatanga tries a through ball, but Nick Proschwitz is caught offside.
Attempt saved. Simon Dawkins (Derby County) left footed shot from the left side of the box is saved in the centre of the goal. Assisted by Conor Sammon.
Corner, Derby County. Conceded by Jean-Yves Mvoto.
Offside, Barnsley. Dale Jennings tries a through ball, but Nick Proschwitz is caught offside.
Attempt missed. Johnny Russell (Derby County) left footed shot from the right side of the box is close, but misses to the left. Assisted by Craig Bryson.
Penalty saved! Johnny Russell (Derby County) fails to capitalise on this great opportunity, left footed shot saved in the bottom right corner.
Penalty Derby County. Conor Sammon draws a foul in the penalty area.
Penalty conceded by Jean-Yves Mvoto (Barnsley) after a foul in the penalty area.
Goal! Derby County 2, Barnsley 1. Nick Proschwitz (Barnsley) left footed shot from the centre of the box to the bottom right corner. Assisted by Lewin Nyatanga with a headed pass.
Corner, Barnsley. Conceded by Lee Grant.
Attempt missed. Chris O'Grady (Barnsley) right footed shot from the right side of the box is close, but misses to the right. Assisted by Stephen Dawson.
Substitution, Derby County. Conor Sammon replaces Chris Martin.
Corner, Derby County. Conceded by Martin Cranie.