Demarai Gray scored the third and final goal for Leicester tonight
January signing Ndidi grabbed his first Foxes goal with a rocket and Gray added a superb solo goal to secure a place in the last 16 and get referee Mike Jones off the hook.
The Foxes were furious when Jones failed to send off stand-in Rams goalkeeper Jonathan Mitchell for clear handball outside his area late in normal time with all three Rams substitutions used up.
It looked like another miserable moment for the Premier League champions, who are fighting against relegation.
But Ndidi’s brilliant strike from more than 20 yards on 95 minutes and Gray’s mazy dribble and super strike settled the tie and gave their side a timely boost despite boss Claudio Ranieri risking more flak by making 10 changes for the fourth-round replay.
Leicester owner Vichai Srivaddhanaprabha had flown 12,000 miles from Thailand to give Ranieri a personal vote of confidence following speculation over the Italian’s future just nine months after he let the club to title glory.
Leicester needed extra-time to beat Derby
And he saw a second-string Foxes side edge ahead through Andy King on 46 minutes before Abdoul Camara equalised for a Derby side featuring eight changes of their own.
Leicester started brightly enough with rarely-seen summer signing Bartosz Kapustka involved heavily in the opening five minutes.
He played a part in an early move that also involved Demarai Gray and Ahmed Musa and ended with Daniel Amartey, just back from the African Cup of Nations, heading over the crossbar.
But Derby responded well and a brief spell of pressure ended with a corner that Ron-Robert Zieler, the stand-in Leicester goalkeeper, punched clear unconvincingly.
Kapustka then sent a long-range shot just over the crossbar before stand-in captain Andy King had a near-post header from Marc Albrighton’s cross deflected behind for a corner.
Abdoul Camara equalised for Derby in normal time
Despite the understudies on view it was a decent contest and Derby twice went close, first when Nick Blackman just failed to get a clean header onto Ikechi Anya’s cross before Abdoul Camara curled a shot a couple of yards wide.
But it was Gray who almost unlocked the door just after the hour-mark with a skillful run past three defenders.
He crossed to the edge of the six-yard box but Musa was inches away from turning it home as he arrived at full stretch.
Leicester had two ambitious penalty appeals rejected as they pushed for a breakthrough before half-time.
Musa went down after minimal contact from Jason Shackell and then Chilwell tumbled after a coming together with Richard Keogh but referee Mike Jones was unconvinced by either case.
Every Premier League club's fastest player this season
Wed, February 8, 2017
Express Sport brings you every Premier League club's fastest player so far this season
1 of 21
Express Sport brings you every Premier League club's fastest player this season
And yet despite a fast-paced start, the contest had petered away as the first half wore on.
Yet the home side were ahead less than two minutes into the second half with a familiar name the scoresheet.
Gray’s cross from the left was headed back at the far post by Albrighton and King had the simple task of nodding home from a couple of yards having used his famous goalscoring instinct to arrive at the perfect time.
Camara twice threatened for Derby but he was unable to make the openings count.
His free-kick from the edge of the area was punched clear by Zieler and his shot from a promising position was dragged wide.
However, Camara grabbed the equaliser on 61 minutes with the aid of some good fortune.
After Albrighton was penalised for a high boot, Julien de Sart took a short free-kick and Camara’s shot from outside the area struck the knee of Leicester defender Ben Chilwell and flew past a helpless Zieler.
Leicester regained the lead just five minutes into extra time when Riyad Mahrez fed fellow substitute Wilfred Ndidi and he strode forward before and burying a left-footed thunderbolt off the post from more than 20 yards.
And substitute Islam Slimani should have made sure of the win moments later but he somehow failed to connect a yard out with Gray’s cross.
Mitchell then made a fine save, diving to his left, to keep out King’s long-range effort.
But Gray made sure with seven minutes remaining when he weaved brilliantly through the Derby defence and bent a superb shot into the top corner.