Immediately after the restart, Andy King got the curtain raiser for the Foxes before Abdoul Camara’s 61st minute deflected freekick took the tie into extra time.
Ranieri introduced the 20-year-old after the regulation period and it took him just four minutes to settle the tie.
The former Genk midfielder was released through the middle by Riyad Mahrez before making forward strides and unleashing a 25-yard missile that cannoned in off the post. Winger Demarai Gray capped off the encounter with a superb solo effort.
The Italian manager was happy with the choice they made in signing the Nigeria international from Belgium.
''I'm happy with Ndidi. This young player is full of personality and good character. We've chosen well,” Ranieri said in a post-match interview.
“For me it (the win) is important for Leicester. When I speak, I speak for Leicester.
“It’s very important this victory and to go through in the cup. It gives us confidence. It was a difficult match.
“When we scored, we played better. Then we scored again and we kept the ball well.”
Ndidi will look to build on this performance when his side, placed a low 16th on the English Premier League log, face fellow strugglers, Swansea City in their next topflight outing on February 12.