Sub Adam Hammill fired Barnsley to an early-season trip to Wembley as his late strike two minutes from time sunk Derby.
With two minutes left, Hammill curled home a trademark strike from 25 yards. The Reds will now head off to play Premier giants Tottenham at the national stadium in the Carabao Cup third round next Tuesday.
Taking on a Derby side which featured 11 changes from the one which thumped Hull 5-0, the Reds almost conceded very early when Johnny Russell broke clear, only to fire meekly at Adam Davies.
The hosts responded with Harvey Barnes cracking a pile-driver against the crossbar from all of 25 yards.
It was the Rams who went in front after six minutes.
Chris Martin expertly teed up Russell; he curled home exquisitely into the corner from 12 yards.
The Tykes evened it up in the 18th minute.
Centre-back Adam Jackson rose to head home his first Barnsley goal from Ryan Hedges’ out-swinging corner.
Back came the Rams, and they ought to have re-taken the lead when Russell side-footed straight at Davies from 10 yards. Eight minutes before the break Derby threatened again.
This time Mason Bennett hung up a terrific cross for Anya, but his header was gather comfortably by Davies.
The compliment was returned 60 seconds later when Bennett tucked home at the far post after sliding in to meet Ikechi Anya’s low cross.
Seconds before the interval Brad Potts should have made it 2-2, but the Reds’ midfielder headed miserably wide from six yards. Tricky left-footer Bennett hammered in a great shot from the edge of the box, with Davies diving full length to save.
With the visit to Wembley still very much up for grabs, the Rams went close to stretching their lead just before the hour mark. Again Wisdom swung over a tempting cross, with Bennett then seeing his pinpoint header tipped brilliantly over the top by ‘keeper Davies.
The Reds levelled matters again in the 74th minute when Tom Bradshaw glided in to convert a low cross from Barnes.
Sub Hammill almost made it 3-2 to the Reds with 10 minutes left when his curling free-kick just whistled past the post, but it mattered not.
The Reds’ fans’ favourite curled home his classic winner with just minutes to spare.
Barnsley (4-3-3): Davies; McCarthy, Jackson, Pinnock, Pearson; Potts (McGeehan, 87), Williams, Moncur (Thiam, 66); Hedges (Hammill, 60), Bradshaw, Barnes.
Subs not used: Townsend, Lindsay, Bird, Ugbo.
Derby (4-2-3-1): Mitchell; Wisdom, Pearce, Shackell, Forsyth; Thorne, Bird (Guy, 80); Anya, Russell, Bennett (Lawrence, 80); Martin.
Subs not used: Roos, Baird, Keogh, Vydra, Nugent.
Referee: Eddie Ilderton (Tyne & Wear).
Star man: Adam Jackson.