The Belarussian world No 3, runner-up here for the last two years, lost her temper and was docked a point for smashing her racket as she suffered a shock defeat 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.
The umpire had already warned Azarenka at the end of the first set for a show of temper and when she infringed again she was docked a point.
"I just felt it was a weird call for me because I had no idea I had a code violation," she said afterwards
"But, I mean, it happened. It didn't help, for sure, but it's okay. It's my own fault."
Playing in her first event since her withdrawal at Indian Wells in March due to an ankle injury, Azarenka said the lay-off had affected her.
"I have been making mistakes that I don't do but that's what comes after not playing for a long time," she added.
"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 had beaten Azarenka once in four previous meetings. 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."
Makarova will play 14th-seeded Frenchwoman Marion Bartoli in the third round.