The Belarusian world number three, runner-up in the last two editions of the premier clay event and coming back from an injury layoff, appeared firmly in control against her 24th-ranked opponent after cruising through the first set.
However, Makarova raised her game to take the second set and after Azarenka smashed her racket on the ground at 3-3 in the decider the Australian Open champion's game fell apart and she suffered her first defeat of the year.
The umpire had already warned Azarenka at the end of the first set and when she took out her frustration on her racquet she was given a point penalty.
"I just felt it was a weird call for me because I had no idea I had a code violation," she said.
"But, I mean, it happened. It didn't help, for sure, but it's okay. It's my own fault," added the 23-year-old.
Azarenka's vanquisher in the 2011 Madrid final, Czech Petra Kvitova, was another high-profile casualty on Wednesday.
Seeded eight in the latest edition, Kvitova surrendered a one-set lead to fall 2-6 6-2 6-3 to Slovakian wildcard Daniela Hantuchova.
Playing in her first event since her withdrawal at Indian Wells in March due to an ankle injury, Azarenka said the lack of competitive action had been a factor in Wednesday's reverse.
She vowed to get back on the practice court before heading to play in Rome as she continues her build-up to the French Open starting at the end of this month.
"I have been doing mistakes that I don't do but that's what comes after not playing for a long time.
"So I still have another tournament before the French Open to compete in and I'm going to go back on the practice court as I always do and work hard to improve.
"I have to give Ekaterina credit. She played well. I felt like I had a lot of chances, I just didn't take them."
Makarova, who will play 14th-seeded Frenchwoman Marion Bartoli in the third round, had beaten Azarenka once in four previous attempts, a 7-6 6-4 success in the final of the Eastbourne grass court tournament in England in 2010.
She now has seven career wins against top-10 opponents but Azarenka is her highest-ranked victim.
"It was really tough in the first set. I didn't play as good as I wanted and I was a little bit angry," Makarova said.
"I don't really like to play against her because it's always tough but I wanted to move her around the court as much as possible and in the second and third sets it worked."
Third round results
16-Ana Ivanovic (Serbia) beat Laura Robson (Britain) 5-7 6-2 7-6(5)
6-Angelique Kerber (Germany) beat Svetlana Kuznetsova (Russia) 3-6 6-4 7-5
Second round results
Daniela Hantuchova (Slovakia) beat 8-Petra Kvitova (Czech Republic) 2-6 6-2 6-3
13-Maria Kirilenko (Russia) beat Kristina Mladenovic (France) 6-7(5) 6-1
Ekaterina Makarova (Russia) beat 3-Victoria Azarenka (Belarus) 1-6 6-2 6-3
Kaia Kanepi (Estonia) beat Carla Suarez Navarro (Spain) 6-3 6-1
Varvara Lepchenko (US) beat Julia Goerges (Germany)WO