The American ninth seed extended her winning streak over the Russian world number two to seven in a row and to eight from 10 meetings, since they first clashed in Miami back in 2004.
Williams, unbeaten on clay this season, battered down 11 aces, including one on a second serve at break-point in the seventh game of the second set, which seemed to end any hopes Sharapova may have had of coming back into the match.
She will meet either fifth-seed Samantha Stosur or Czech qualifier Lucie Hradecka in the semifinals.
World number one Azarenka was made to battle hard to overcome Roland Garros champion Li Na 3-6 6-3 6-3.
The Belarussian, runner up in Madrid last year, looked to be cruising at 4-1 up in the third before China's Li broke back.
Li was unable to take advantage of four break-point chances, however, and 36 unforced errors told its own story.
Asked if it was confidence from having won four titles already this year that had seen her through the match, Azarenka responded, "It wasn't very much to do with confidence.
"I was thinking I had to change and come up with things to surprise her because she was playing unbelievable in the first set. I had to turn something around.
"I don't know if it was confidence, or belief, or whether it was just pushing myself to be better."
Azarenka also gave her views on the controversial blue clay playing surface, an innovation at this year's tournament, which men's world numbers one and two Novak Djokovic and Rafa Nadal slammed on Thursday.
"I'm not a fan of this court, that's for sure," she added.
"But I don't want to sit here and complain about it. Nothing is going to change this year. We can talk after the tournament about maybe possible changes or something."
Azarenka will face newly-installed world number three Agnieszka Radwanska or American qualifier Varvara Lepchenko in the last four.
Maria Sharapova of Russia reacts after losing a point to Serena Williams of the US during their women's quarterfinal singles match at the Madrid Open tennis tournament in Madrid May 11, 2012 (Photo: Reuters)