Match ends, Leicester City 3, Derby County 1.
Leicester secured a first home win of 2017 as Demarai Gray's superb solo goal sealed an extra-time victory over Derby in their FA Cup fourth-round replay.
Andy King headed the hosts, who made 10 changes, ahead after Gray's clever cross was nodded back across goal by Marc Albrighton.
Abdoul Camara's free-kick forced extra time for Championship Derby only for substitute Wilfred Ndidi to restore the Foxes' lead with a fantastic strike.
Gray sealed a deserved win with an angled finish after a fine run.
Premier League Leicester will now face League One Millwall in the last 16 on 18 February (15:00 GMT).
- 'Win can kick-start our season'
- Reaction from the King Power Stadium
- 5 live podcast: Nifty Shades of Gray
Smiles for Ranieri - at last
Claudio Ranieri has not had too much to cheer about lately as last season's champions have been plunged into a fight for Premier League survival.
Yet the Italian was all smiles and applauded home fans as they chanted his name around the King Power Stadium soon after King's opener.
Leicester, 16th in the table and one point above the relegation zone, face a battle to climb away from trouble but their first win since 7 January will at least provide them with some momentum.
A spirited Derby display - and a poor performance from the officials - made sure it was anything but a straightforward win.
The hosts should have won a first-half penalty when Ben Chilwell was sent sprawling inside the area by Richard Keogh but referee Mike Jones was not interested.
There was more controversy in the 85th minute when Derby keeper Jonathan Mitchell clearly handled outside his area but Leicester's Ahmed Musa was booked for protesting after Jones dismissed the home team's appeals.
Derby left to focus on play-offs
Although there was disappointment from Rams boss Steve McClaren, his team gave Leicester two tough games.
Derby led until four minutes from the end in the original game and forced Leicester into extra time on their own ground before running out of steam.
It might have been a different story had Ron-Robert Zieler not palmed away Jacob Butterfield's low drive on the stroke of half-time. By the time McClaren reached the dugout for the second half, his side were behind - King giving Leicester the lead in the opening minute of the second half.
The Rams responded well to falling behind. Camara had a free-kick beaten away before the Guinea international found the net with a 25-yard set-piece that deflected off Chilwell's thigh on its way into the net.
Derby's Max Lowe chested against his own post while attempting to guide the ball back to his keeper before two sublime finishes took the tie away from the visitors.
Ndidi fired home via the post from 25 yards then Gray, energetic and dynamic throughout, made it 3-1 after avoiding several challenges before his clinical finish allowed Leicester fans to celebrate a welcome victory.
All change - cup gets second billing
Both teams seemed to have their eyes on this weekend's games as they made 18 changes between them.
Musa was the only survivor from the Leicester side that started last weekend's match with Manchester United even though the Foxes are not in action again until Sunday.
Derby, despite bringing 5,000 travelling fans, made eight changes, as they also rested players to aid their play-off push.
"I didn't want to make eight changes. If the game was last night the team would have been totally different," said McClaren.
However, pundit and former Leicester midfielder Robbie Savage was critical of the number of changes made by both managers.
He said: "If Derby County were playing three Championship games in a week and chasing promotion would they put this team out? It's absolute nonsense. Play your best team."
Man of the match - Demarai Gray (Leicester City)
'This fresh air is good for us'
Leicester boss Claudio Ranieri: "Derby played good football and we won. This is what we needed and I wanted.
"We want to do well in all competitions. We want to go forward in the FA Cup. The Premier League is not so good but we have to stay in the Premier League. This fresh air is good for the players."
Derby County boss Steve McClaren: "There are some very tired players in the dressing room. It was always going to be hard work.
"We had a go and I can't fault the players. We ran out of steam in the end. We missed our opportunity in the first game."
Sunday's Premier League game at fellow strugglers Swansea City (16:00 GMT) is a huge match for Leicester. Derby will look to strengthen their Championship play-off bid with a home victory over Bristol City (15:00 GMT) on Saturday.
- 24MendyBooked at 9minsSubstituted forNdidiat 90'minutes
- 14KapustkaSubstituted forMahrezat 81'minutes
- 7MusaBooked at 84minsSubstituted forSlimaniat 90'minutes
- 2ChristieBooked at 5mins
- 17de Sart
- 15JohnsonSubstituted forVydraat 53'minutes
- 20CamaraSubstituted forRussellat 74'minutes
- 22BlackmanSubstituted forNugentat 82'minutes
- Mike Jones
- Shots on Target
Second Half Extra Time ends, Leicester City 3, Derby County 1.
Corner, Derby County. Conceded by Daniel Amartey.
Foul by Jacob Butterfield (Derby County).
Andy King (Leicester City) wins a free kick in the defensive half.
Attempt missed. David Nugent (Derby County) header from the centre of the box misses to the left. Assisted by Cyrus Christie with a cross.
Corner, Derby County. Conceded by Wilfred Ndidi.
Corner, Derby County. Conceded by Ben Chilwell.
Goal! Leicester City 3, Derby County 1. Demarai Gray (Leicester City) right footed shot from the centre of the box to the top right corner. Assisted by Marc Albrighton.
Attempt saved. Wilfred Ndidi (Leicester City) header from the right side of the six yard box is saved in the bottom right corner. Assisted by Riyad Mahrez with a cross.
Corner, Leicester City. Conceded by Johnny Russell.
Corner, Leicester City. Conceded by Jonathan Mitchell.
Attempt saved. Andy King (Leicester City) right footed shot from outside the box is saved in the bottom right corner. Assisted by Riyad Mahrez.
Second Half Extra Time begins Leicester City 2, Derby County 1.
First Half Extra Time ends, Leicester City 2, Derby County 1.
Corner, Derby County. Conceded by Yohan Benalouane.
Attempt missed. Johnny Russell (Derby County) header from the centre of the box misses to the left. Assisted by Cyrus Christie with a cross.
Foul by Islam Slimani (Leicester City).
Jason Shackell (Derby County) wins a free kick in the defensive half.
Foul by Wilfred Ndidi (Leicester City).