There was also misery for defending champion Vera Zvonareva who quit with a hip injury midway through her second-round match against Romania's Monica Niculescu.
Czech left-hander Safarova saved three match points in the third set and played a superb tiebreaker to set up a third-round clash with Russian Svetlana Kuznetsova, who defeated compatriot Maria Kirilenko 6-4, 6-4.
Wozniacki, seeded two but now ranked at four in the world, was deposed from the world top spot when she was knocked out of the Australian Open quarter-finals.
"I just want to get out of here [the media conference room]. You don't want to stay when you lose a match like that," said Wozniacki who was runner up twice in Doha - in the 2010 season-ending championships and last year's Qatar Open.
There were no such problems, however, for newly crowned world No 1 and Australian Open champion Victoria Azarenka who cruised into the third round, beating Germany's Mona Barthel 6-1, 6-0.
Safarova, who is 2-1 in career clashes with Wozniacki, said: "Unless you win the final point, the match is not over.
"I just wanted to keep fighting. It feels absolutely amazing," added the 25-year-old, who has won four titles on the WTA Tour.
Wozniacki made several unforced errors on big points to allow Safarova back into the match in the second set.
The Dane also failed to take advantage of three match points in the 10th game of the third.
Buoyed by the let-off, Safarova really turned it on in the tiebreaker, pulling away after the scores were tied 3-3, a lucky net cord giving her a 4-3 lead. A cracking double-handed backhand passing shot enabled the Czech to go up 5-3.
Earlier, fourth-seeded Agnieszka Radwanska of Poland thrashed Britain's Anne Keothavong 6-1, 6-2, while French fifth seed Marion Bartoli also had it easy, beating Spaniard Anabel Medina Garrigues 6-2, 6-0.
Serb eighth seed Jelena Jankovic fell to Israeli Shahar Peer 7-6 (7-4), 6-2, while her compatriot Ana Ivanovic also bowed out, losing 6-4, 6-4 to the Czech Republic's Petra Cetkovska.
- AAP