Sharapova, the 30 seed, won 6-4, 4-6, 6-3 against the tournament's defending champion in a match that took 2:24.
"It was a good win," Sharapova told reporters. "I feel pretty happy about it ... It was a match that I looked forward to when the draw came out. I thought it was, as usual and expected, a physical match. It didn't have to be in some ways. I thought that in the longer rallies I did a great job of winning those. I put a lot of pressure on her."
Wozniacki went up 4-1 in the first set before Sharapova roared back. Sharapova went on to take the set by winning five consecutive points.
Sharapova fell down 3-0 in the second set, before rallying to get to 3-3. Wozniacki took a 4-3 edge before Sharapova tied it at 4-4. Wozniacki finished off the set by winning two consecutive points.
The third set was much tighter. Wozniacki took a 3-2 lead in the set before Sharapova sparked the victory by closing her out with three consecutive points.
"I did my best out there," Wozniacki said. "I was fighting until the end. In my head, I should have won that first set. Being up 4-1, I had a chance to do that. I didn't. I fought back and won the second set and it was a close third set. It just wasn't enough today. I did my best. I did all I could and I just came up short."
Sharapova last won at Melbourne in 2008. Her last grand slam came at the 2014 French Open. American Amanda Anisimova also advanced to the fourth round in an upset over No. 11 Aryna Sabalenka. No. 2 Angelique Kerber, No. 5 Sloane Stephens, No. 8 Petra Kvitova, Danielle Collins, Ashleigh Barty and Anastasia Pavlyuchenkova also advanced to the fourth round.
No. 2 Rafael Nadal beat No. 27 Alex De Minaur in straight sets as the top men's player to advance on Friday to the fourth round. No. 3 Roger Federer, No. 6 Marin Cilic, Stefanos Tsitsipas, Tomas Berdych, Frances Tiafoe, Roberto Bautista and Gregor Dmitrov also advanced to the fourth round on the men's circuit.