Wozniacki was unable to overcome Petkovic, the world number 23
World number one Caroline Wozniacki went out of the Sony Ericsson Open in Miami with a 7-5 3-6 6-3 fourth-round defeat by Andrea Petkovic.
An out-of-sorts Wozniacki dropped the first set having squandered three set points with the score at 5-4.
But the Dane dug deep to clinch the second before world number 23 Petkovic held her nerve to serve out the final set with a confident love hold.
"I had a strict game plan and stuck to it. That was the key," said Petkovic.
Wozniacki struggled to settle into any kind of rhythm as her German opponent forced her into a string of unforced errors.
The Dane, looking to become just the third player to win both the Indian Wells and Miami Open titles back to back, struggled with her forehand throughout.
Petkovic saved 12 of 17 break points and held firm to record her first win against a world number one.
I'm just going to take a few days of rest now. I need that, you know - maybe on the beach, get some of the tan lines off
"Most of the players think they can overpower Caroline," said Petkovic. "I think that's the wrong approach, because that's where she's most comfortable, when she can run and bring the most balls back.
"What I try to do is mix it up and to make her play, and then when I had the short ball to go for it."
Wozniacki, who has guaranteed she will retain the number one ranking for at least three more weeks, said: "I'm just going to take a few days of rest now. I need that, you know - maybe on the beach, get some of the tan lines off.
"Of course I would have loved to have won today, but it didn't happen. I'm not going to dig a hole for myself, or dig a grave. I will just take a few days of rest and I'm prepared for the clay season."
Petkovic goes on to face sixth seed Jelena Jankovic in the quarter-finals after the Serbian beat Anabel Medina Garrigues of Spain 6-1 6-3.
Meanwhile, 16th seed Maria Sharapova extended her winning streak over Samantha Stosur to seven with a convincing 6-4 6-1 win over the Australian.
Having battled to clinch an uneven first set, a more confident Sharapova swiftly opened a double-break cushion in the second before easing to victory.
It was an impressive result for the Russian, who has now reached the last eight of the Florida event for the third time.
"Stosur is in the top five players in the world so this is a great win for me," said Sharapova.
Next up for the three-time Grand Slam champion will be Romania's Alexandra Dulgheru after her 6-3 6-4 win over Peng Shuai of China.
Russian third seed Vera Zvonareva battled past France's Marion Bartoli 2-6 6-3 6-2, and ninth-seeded Pole Agnieszka Radwanska handed a 6-0 6-2 thrashing to Italian fifth seed Francesca Schiavone.
Eighth seed Victoria Azarenka of Belarus fought back from set down to see off Russian 17th seed Anastasia Pavlyuchenkova 3-6 6-1 6-4.
The match between Belgian second seed Kim Clijsters and Serbia's former world number one Ana Ivanovic was postponed after heavy rain washed out the evening session in Miami.