WATCH the WTA Tour LIVE & ONLY on beIN SPORTS | available via Foxtel, Kayo Sports, Fetch TV & beIN SPORTS CONNECT
Australia's Barty broke five times, the last when Azarenka netted a forehand volley to end matters after one hour and 52 minutes at Hard Rock Stadium.
Barty, who had to save a match point on the way to a three-set victory over Kristina Kucova in the second round, will next face the winner of a later match between seventh seed Aryna Sabalenka of Belarus or Czech 19th seed Marketa Vondrousova.
The 2019 French Open winner dominated the first set but Azarenka broke her for a 2-0 lead in the second, then fought back from 0-40 down to hold for 3-0 on the way to forcing a third set, the Aussie failing to a point off her second serve in the second set.
Barty and Azarenka traded breaks in the second and third games of the final set. Azarenka denied Barty on two break chances in the fourth game but the 24-year-old Queenslander broke in the sixth to seize the lead and again on the final point.
Ukraine's fifth-seeded Elina Svitolina rallied to defeat Czech ninth seed Petra Kvitova 2-6, 7-5, 7-5.
"I'm really happy with how I bounced back from being a set down," Svitolina said. "I'm happy with how I'm playing and handling the pressure. I had to bring my best game to win."
She was also pleased with how well she has handled playing two three-setters in hot and humid conditions.
"I feel pretty fresh," Svitolina said. "I'm pretty surprised. I'm feeling good. Ive been working really hard on my fitness and it's paying off I guess."
Svitolina's quarter-final foe will be either Croatia's 338th-ranked Ana Konjuh or Latvia's 57th-ranked Anastasija Sevastova.