(CNN) -- Top seed Rafael Nadal was given a scare before being handed a place in the semifinals of the Shanghai Masters.
Rafael Nadal is through to the Shanghai semis after opponent Ivan Ljubicic was forced to withdraw.
Ivan Ljubicic took the first set of their quarterfinal before the Spaniard advanced when his opponent had to withdraw because of a thigh injury with the score at 3-6 6-3.
A single break, courtesy of a Nadal forehand error, was enough for Ljubicic to claim the first set and the Croat had the chance to break at 1-1 in the second, but Nadal battled to save four break points and took advantage by breaking Ljubicic to love in the next game.
Nadal held his nerve to claim the set, but by then Ljubicic's discomfort had become obvious and he was unable to serve at the start of the third. A meeting with the great Rafael Nadal
The Spaniard will now face unseeded compatriot Feliciano Lopez, who beat Robin Soderling of Sweden 7-6 6-3 to reach his first semifinal of the year, for a place in Sunday's final.
Second seed Novak Djokovic also had an uncomfortable day, needing three sets to seal a 6-3 2-6 6-2 win over Gilles Simon -- a match which turned on a topsy-turvy start to the third set.
The Serb needed two breaks to overcome stubborn Simon, who kept biting back at him, in the first set -- and the Frenchman's dogged defence saw a frustrated Djokovic go to pieces in the second as he produced a host of enforced errors.
The third set started with three successive breaks, before Djokovic broke again in the seventh game before serving out to secure victory.
"In the second set I made a lot of unforced errors," Djokovic told Sky Sports. "He was a tough opponent -- he is one of the trickiest players on the tour. I was very aggressive in the third set and I think it paid off."
Next up for Djokovic is Russian sixth seed Nikolay Davydenko, who defeated Czech Radek Stepanek 6-1 4-6 6-1.