Extra-time goals from comeback man Claus Jensen and fellow sub Collins John put Fulham into the fifth found of the FA Cup, but it was so harsh on Derby.
The Rams were outstanding in the first half when they went 1-0 up through Grzegorz Rasiak only to be pegged back by a Papa Bouba Diop penalty.
And the Championship side responded superbly when Luis Boa Morte made it 2-1 by scoring a last-gasp equaliser through sub Paul Peschisolido.
That took the match into extra time and Fulham's Premiership class finally told as John and Jensen - finally back from four months out with a hamstring injury - made the match safe.
Derby ended the match with ten men after captain Michael Johnson went off injured in extra-time and their fate was sealed, leaving Fulham with a fifth round tie at Bolton next weekend.
It was a thrilling game, and in the end a fantastic win for the home side. But they will wonder how on earth they managed it after a disastrous first half.
It started after only four minutes w hen the home defence fell asleep as the influential Inigo Idiakez took a quick free-kick down the right and found Tommy Smith.
The striker sped into the box and slid a perfect low ball across the box for top scorer Rasiak to finish smartly.
Fulham were stunned, and they took a long time to recover as Derby dominated possession for the next 15 minutes and looked capable of cutting through the Fulham defence at will.
Idiakez had a shot saved following a neat pull-back from the impressive Morten Bisgaard after six minutes and Bisgaard himself forced Edwin Van der Sar into action with a shot from distance a few minutes later.
It was almost 2-0 after 14 minutes when Fulham defender Zesh Rehman headed a deflected cross against his own bar and you could sense the home crowd were becoming restless.
They did, however, have a glorious chance to equalise after 34 minutes when Tomasz Radzinski somehow volleyed a Boa Morte cross over the bar.
Fulham were almost punished because within seconds Bisgaard hared up the other end of the field, beat his man with an outrageous dummy and fired a low shot only narrowly wide.
Then the visitors struck the bar, direct from a corner, and saw a Rasiak header cleared off the line by Radzinski.
It looked like they would go into the break comfortably ahead with Fulham's chins right on the floor, but then fate stepped in.
With only seconds to go in injury time referee Pete Walton handed the home side a soft penalty when Johnson handled the ball as he tried to tackle Diop.
To the horror of the away fans Diop struck a superb penalty high into the right-hand corner of the net for 1-1 and there was worse to come.
With only four minutes on the clock in the second half, Boa Morte threaded a right-foot shot tamely into the net from the edge of the area and Fulham, against all the odds, were ahead.
Derby didn't give up, however, and continued to create a string of chances, with Van der Sar saving superbly from Bisgaard. Keeper Lee Camp kept them in it at the other end with an amazing double close-range save from Boa Morte.
Then, with time running out, they finally got the equaliser they deserved when Idiakez struck a ferocious, swerving free-kick from 20 yards.
Van der Sar somehow managed to scoop it out from just under the bar, but sub Peschisolido - a former Fulham hero, slid the ball home from close range to set up extra-time.
Fulham, to their credit, didn't crack under the pressure. And they were back in front four minutes into extra-time when their own sub, John, turned superbly to smash home a left-foot shot.
Derby lost captain Johnson to injury soon after that, leaving them with only ten men on the field and Fulham wrapped things up through another sub, Jensen.
With almost his first touch he ran on to a Radzinski pass and classily finished left-footed past keeper Camp with 105 minutes on the clock.
Man of the Match: Grzegorz Rasiak
The Polish striker was a constant threat and deserved his goal, but did not deserve to finish on the losing side.