Bartoli hands Azarenka first defeat of 2012
Azarenka's season-long unbeaten run had earned her four titles, including her first Grand Slam at the Australian Open, which propelled her to world number one.
Bartoli (L) celebrates after winning against Azarenka (R).
The 22-year-old from Belarus also won in Sydney, Doha and Indian Wells.
It was the longest winning streak on the WTA Tour since Martina Hingis won 37 consecutive matches in 1997."I feel disappointed, sure," Azarenka said. "Who wouldn't be after the loss?
"But what I've done in the last couple of months, I have to be really proud of myself. I could have maybe played better today, that's for sure, but I gave it all I had.
"Physically I was just not able to do anything today. It was just not possible."
Defending champion Azarenka fell behind early in the match against her French opponent and was unable to turn it around as she had in her fourth-round match two days ago.
Down a set and behind 5-2 against 16th seeded Dominika Cibulkova, she had rallied to win in three sets, 1-6, 7-6 (9/7), 7-5, but could not engineer a similar comeback against Bartoli.
"Everybody wanted to be the first one to beat me," Azarenka said. "I think it's pretty normal. When I was going to play against the number one player in the world I also tried to do the same.
"Two days ago I could turn it around and today I couldn't. But it's not gonna stop me from working hard and keep going the same way."
Defending champion Azarenka has won twice before in Miami, but has now lost two of her last three meetings with Bartoli.
"I'm just tired," she said. "This is expected. But what can you do? That was supposed to happen one day.
"I couldn't kept going all the way. To play these tournaments back-to-back is really difficult physically.
"I'm not really worried about anything else. It was just I wasn't able to do anything physical today."
Bartoli, 27 and ranked at a career-high seventh in the world, will play fifth-seeded Agnieszka Radwanska of Poland for a place in the final.
Bartoli notched her third career victory over a world number one player. She beat Belgian Justine Henin at Wimbledon in 2007 and Serbia's Jelena Jankovic at the Australian Open in 2009.
"I honestly have never seen her play that well," Azarenka said. "All the credit to her. She did an amazing job today."
Bartoli, who has yet to win a title this year, capitalised on six of 10 break-point opportunities to secure just her third win in 11 meetings with Azarenka.