Djkovic's win set up a clash with German Tommy Haas, who beat Ukrainian Alexandr Dolgopolov 6-3 6-2.
"It was very difficult to kind of get into a rhythm because you couldn't really serve at 100 percent," Djokovic, the two-time defending champion, told reporters.
"You had to go more for precision and put twice as much effort into the step adjustments because of the windy conditions. All in all, I'm just happy to get through the rough day."
The top-seeded Serb took 28 of his 31 first-serve points and faced just one break point in the 68-minute victory.
Haas, seeded 15th, moved through to the fourth round for the first time since 2001. He hit 13 aces and saved seven of the eight break points against his serve.
"He's probably one of the most experienced active players in the world now," Djokovic said of the German. "He can play equally well on any surface."
Spain's world number five David Ferrer outlasted Italian Fabio Fognini 6-1 7-5 and Japan's Kei Nishikori, Ferrer's next opponent, beat Xavier Malisse of Belgium 6-2 7-5.
World number two Sharapova, who is on an eight-match winning streak, fell behind 3-1 in the first set but won 11 of the next 14 games to advance in straight sets.
"It wasn't easy for the both of us with the heat and the wind," Sharapova said. "It was just one of those days where you know you might not be playing your best tennis. I certainly wasn't today."
The third seed next faces Czech Klara Zakopalova, who beat Russia's Maria Kirilenko 6-2 7-6.
Romanian Sorana Cirstea pulled off Sunday's biggest surprise, taking out sixth seeded Angelique Kerber of Germany 6-4 6-0.
After Kerber held at 4-4, Cirstea won eight games in a row - and lost just seven points in those eight games.
"I didn't have any expectations coming into this tournament because I've never played that well in Miami," Cirstea said.
"But I've been fighting the best I could and working my way through every single match, and it's working."
She draws former finalist Jelena Jankovic of Serbia, a 7-6 6-4 winner over Russian Nadia Petrova.