The 22-year-old Barty was ultimately let down by her groundstrokes in crucial stages of decider as she finished with 54 unforced errors for the match.
Wozniacki will next face former French Open semi-finalist Kiki Bertens, who stunned 15th seed Anastasija Sevastova 6-1 6-4 in the second round.
"It'll be another tough match," said Wozniacki. "She's a big server with a big forehand. She loves the clay.
"I haven't had an easy draw here, but I don't think anyone has. It's just about going for it again. That's all I can do, is go out there and do my best.
"I think it's definitely a surface that I think evens out a lot of the playing field. I think there are more people that have an opportunity here on this surface."
Karolina Pliskova, meanwhile, held off former world number one Victoria Azarenka 6-2 1-6 7-5 to set up a third-round clash with U.S. Open champion Sloane Stephens.
Belarusian veteran Azarenka was featuring in her first tournament on clay for two years and came from 3-0 down to level in the final set against Pliskova.
However, the Czech broke serve in the 11th game to win a tense battle.
Another former world number one, Maria Sharapova, continued her revival on clay as she overcame a tense opening set to beat Romania's Irina-Camelia Begu 7-5 6-1.
The 31-year-old Russian, who entered the tournament on the back of four consecutive defeats, rallied from 3-1 down before snatching the opening set with a ferocious forehand.
With momentum on her side, Sharapova won 20 of the last 22 points to secure a spot in the last-16.
"Although I didn't play at my best level in the first set, I pulled it through," the five-time grand slam champion told a news conference.
"I played some really tough points. I hung in there, especially in that final game. Then I really set up a good opportunity for me to step up.
"I thought I did a really good job of that, especially in the last six games. I was very aggressive, played deep, returned a lot better. That will certainly help me moving forward."
Unseeded Sharapova will next face last year's finalist Kristina Mladenovic, who edged China's Zhang Shuai 6-4 4-6 6-3.