The Serbian, who was disqualified from the US Open after accidentally striking a ball at a line judge, beat Krajinović 7-6, 6-3 at Foro Italico. He now has one week to regroup before he attempts to win a record-extending 13th French Open title.
Nadal will face Diego Schwartzman of Argentina in the last eight.
Djokovic, who has reached the last eight in Rome each year since 2007, improves to 11-3 in Rome quarter-finals.
At 5-4 ahead in the second set he was broken to love by 12-time French Open victor Nadal.
"It's been nice to see people in the crowd, even if they were not supporting me at all today", said Halep. "But today I did my best and I'm very happy".
Less than two weeks after being disqualified from the U.S. Open, Novak Djokovic's frustration boiled over once again as he smashed his racket in a fit of rage during his 6-3 4-6 6-3 win over Dominik Koepfer in the Italian Open quarter-finals on Saturday.
In Djokovic's 10th Rome final - he has won four - he " ll face either eighth-seeded Diego Schwartzman or 12th-seeded Denis Shapovalov.
The nine-times Rome champion, who had won all nine previous meetings against Schwartzman, struggled with his serve throughout the match and made a series of uncharacteristic unforced errors that proved to be his undoing.
Wimbledon champion Halep held off a fightback from her Spanish rival.
Djokovic's behaviour once again overshadowed his performance, in a match where he had to save two set points when Ruud served for the first set at 5-4 - one of them with a delicate backhand drop-shot victor. Entering the match, she had been on court for 7 hours, 22 minutes - far more than Halep, who had a bye in the opening round and won her next two matches in straight sets.
Halep has twice finished runner-up in Rome in 2017 and 2018, and "really wants to win" the tournament.
After winning a title in Dubai before the lockdown, Halep marked her return after tennis' five-month break with another trophy in Prague last month.
Champion Nadal was making his comeback after a six-month coronavirus-enforced break having skipped the US Open ahead of Roland Garros with its first round on September 27.
To reach the same stage this year, Schwartzman will need to beat the Spaniard for the first time after failing in his previous nine attempts, halting Nadal's 12-match unbeaten run at the tournament. "But I'll try to take the positive aspects out of it", Sinner said.
"That's just me", Djokovic said. "Never easy, I think, emotionally to play against someone that is one of my best friends for many years.I think the first set could have gone a different way, as well". I'm feeling like it's a weird tournament and is not the best tournament (to win) for the first time against Rafa.