The in-form Serb had dropped only four games in her two previous matches but she was caught out by the superior attacking tactics of Safarova for almost two sets.
The 20-year-old Czech trailed 3-1 in the first set before finding her range and she stunned Jankovic with a series of pin-point drive volleys.
After winning the first set on a double fault, Safarova kept up the pace in the second but Jankovic hung on to take it 7-4 in the tiebreak.
A 30-minute rain delay appeared to have come in the nick of time for Jankovic, who was struggling with a thigh strain and on resumption she ran away with the decider. An erring backhand from Safarova settled the high-quality contest.
Jankovic will next play either France's Marion Bartoli or Shahar Peer of Israel in an attempt to reach the quarter-finals here for the first time.