The champions, in a welcome break from their Premier League form, needed extra time to see off their Championship opponents and goals from Onyinye Ndidi and then Demarai Gray in the additional half an hour did the trick to set up a trip to Millwall in the fifth round later this month.
Andy King, captain for the night, headed Leicester in front at the start of the second half but Abdoul Camara’s deflected free-kick brought Derby level just after the hour.
The replay victory will be a relief for Ranieri, who on Tuesday was given the vote of confidence by the club.
Ranieri’s selection dilemma ahead of the tie was whether to make wholesale changes and rest players ahead of Sunday’s crucial Premier League clash against relegation rivals Swansea, or field something close to a first choice starting line up. The Italian made 10 changes with Ahmed Musa the only survivor from the defeat to Manchester United.
Derby had their own agenda, securing a Championship play-off spot is their aim, and Rams boss Steve McClaren made eight changes.
With so many alterations, both sides lacked fluency and chances were few and far between during the 90 minutes after Daniel Amartey looped a header onto the roof of the Derby net early on.
Leicester appealed for a penalty midway through the first half following a coming together between Musa and Jason Shackell but referee Michael Jones rightly played on.
Jones was asked to make another call on a spot-kick six minutes before half-time when Derby captain Richard Keogh barged over Ben Chilwell but once more the official ignored the host’s protests.
The second half was less than a minute old when Leicester made what had looked like an unlikely breakthrough. Gray’s deep cross was headed back across goal by Marc Albrighton and King nodded the ball home from inside the six yard box.
Derby equalised just after the hour when Camara’s free-kick flicked off Chilwell’s knee and past Zieler.
Leicester felt aggrieved when Derby goalkeeper Jonathan Mitchell escaped punishment for handling the ball outside of his area, after Musa was first to a pass over the top.
It seemed luck was destined to be with Derby on the night as in the final minute Max Lowe, with no Leicester player in sight, calmly chested a cross against his own post.
However, early in extra time Leicester led again through Ndidi. On as a substitute at the start of extra time, the January signing from Genk unleashed a shot from outside the area which flew in.
Russell came close to an equaliser with a header but Leicester were in the ascendancy and Mitchell saved well to deny King before Gray settled it after 114 minutes, showing quick feet down the left side of the penalty box before firing a shot into the roof of the net.
Zieler, Amartey, Wasilewski, Benalouane, Chilwell, King, Mendy (Ndidi 91), Albrighton, Kapustka (Mahrez 81), Gray, Musa (Slimani 91).
Mitchell, Christie, Keogh, Shackell, Lowe, Butterfield, de Sart, Johnson (Vydra 53), Camara (Russell 74), Blackman (Nugent 82), Anya.
Mike Jones (Cheshire).