Wozniacki battles through in Miami
The world number one - fresh from picking up her second tournament trophy of the season in Indian Wells last week - claimed a comfortable first set 6-2, before appearing to put one foot in the third round with a 5-3 lead in the second.
However, American Mattek-Sands launched a stirring fightback before being eventually dispatched 7-5 in the second set.
Wozniacki will face Daniela Hantuchova in the third round, after the Russian ousted another US hopeful, Melanie Oudin, 7-5 6-3.
Fourth-seed Sam Stosur enjoyed a comfortable outing against Zheng Jie, thrashing the former world number 15 6-2 6-1 in just 58 minutes.
The Australian won nine straight games from 2-2 in the opening set, and rarely looked threatened as she booked a third round meeting with Lucie Safarova - who beat Patty Schnyder 6-2 6-4 in their second round match.
"I played quite well. I don't think I hit the ball out of this world fantastic, but I did what I had to do," Stosur said.
"Against a player like Zheng, you want to be able to do that from start to finish. She competes hard for every single point."
"Lucie is a good player who can pretty much beat anyone on her day," Stosur said of her next opponent, Safarova. "I haven't played a lefty for a while. That's something I'll have to adjust to, especially on the return. Hopefully I'll have a good match."
There were no problems for Russia's Svetlana Kuznetsova, who beat Simona Halep 6-0 6-4, while her compatriot Maria Sharapova coasted through 6-3 6-2 against Petra Martic of Croatia.
Sixth-seed Jelena Jankovic also advanced - with a 6-3 6-1 victory over Monica Niculescu - but 10th-seed Shahar Peer and 13th-seed Flavia Pennetta crashed out against Anabel Medina Garrigues and Iveta Benesova respectively.
Yanina Wickmayer, seeded 23, also went out of the tournament, the Belgian losing a three-setter 6-2 5-7 6-4 to Russia's Elena Vesnina.