The third seed battled through temperatures of up to 42 Celsius (107.6 Fahrenheit) and a third set lasting nearly two hours to overcome the 44th-ranked Knapp 6-3, 4-6, 10-8.
The four-time Grand Slam champion was forced to stay on court for three hours 28 minutes as she seeks her first major title since the French Open in 2012.
The conditions were so tough that organisers suspended play at the tournament midway through the third set. However, under tournament rules, Sharapova and Knapp had to finish the set before coming off.
"The recovery for me will be really important but these are the matches you train for and I'm really happy to be through."
Also Read
Now under coach Sven Groeneveld after a failed, one-tournament partnership with Jimmy Connors, the 26-year-old is coming back from shoulder surgery, and she struggled against Knapp.
Her serve let her down and she only converted seven of 20 break points.
Sharapova got the match at Rod Laver Arena underway by holding serve and Knapp did the same as the two players got the measure of their games.