A late Adam Hammill winner gave Barnsley a 3-2 win against Derby to set up a third round Carabao Cup tie against Tottenham.
Derby took the lead twice but Barnsley fought back to secure a game against Spurs at Wembley.
Barnsley went close in the fifth minute with midfielder Brad Potts producing a brilliant long-range effort, smashing against the crossbar and going wide.
Derby took the lead in the seventh minute with Chris Martin finding Johnny Russell and he brilliantly curled the ball in from just inside the area.
Barnsley should have been level in the 12th minute when a surging run and shot from right back Jason McCarthy led to Tom Bradshaw shooting well over from close range.
The Tykes equalised in the 18th minute when a corner whipped in from the right by Ryan Hedges was headed in by Adam Jackson.
Mason Bennett put Derby back in front in the 40th minute following a superb cross across the face of goal from winger Ikechi Anya.
The second half started slowly but in the 68th minute Bradshaw slid home a Harvey Barnes cross to bring Barnsley level again.
Substitute Hammill was the difference in the second half for the hosts and nearly put his side into the lead, putting a 25-yard free kick narrowly wide.
It was Hammill who produced the winner in the 88th minute, when he cut inside from the left onto his right foot before placing the ball perfectly into the far corner.