Going in, Makarova's best win was against a No.4-ranked Petra Kvitova at Eastbourne last year - she was 0-9 against the Top 3, losing eight of those in straight sets and the other one 6-0 in the third.
And things looked headed the same way this time as she dropped the first set, 6-1 - but Makarova shifted strategy early in the second set and eventually overcame the No.3-seeded Azarenka, 16 62 63, showing some fight too - she won five games in a row from 3-1 down in the third to close it out.
"We played many times before and I didn't win so much - I'm not that comfortable against her game," Makarova said. "It was a really tough first set for me - when I came out I wasn't playing as well as I wanted to, then I got a little bit angry and it was really tough to change my game and my mentality.
"But coming into Madrid I was feeling good - I played some good matches in Fed Cup and I think that gave me a little bit more confidence on clay, and I really enjoy these clay courts because it's a little bit faster here. I just tried to move her around more in the second and third sets and it worked.
"I'm so happy I came through it today."
Azarenka was gracious in defeat - a defeat that put an end to her perfect 18-0 start to the year.
"I have to give Ekaterina credit - she played really well," Azarenka said. "I felt like I had a lot of chances; I just didn't take them. I put myself down a little bit. Hey, I didn't play for a long time. I haven't lost a match for a long time. But this happens - it was going to happen sooner or later anyway.
"I just want to do better in the next tournament and kind of pick it up."
Before Madrid, Azarenka had been out for almost two months with an ankle injury, an ailment that caused her to miss a slew of big tournaments, most notably her former conquering grounds in Miami.
"It was really noticeable," Azarenka said. "I was doing mistakes I don't normally do - but that's what comes after not playing a long time. 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.
"It's just a matter of playing more matches now, just being in competition and working hard from here. Today was definitely a good learning lesson for me to step forward and improve from here."
Other early winners on Wednesday as the second round continued were Kaia Kanepi, who won 12 of 14 games from an early 2-0 hole to beat Carla Suárez Navarro, 63 61, avenging a semifinal defeat in Oeiras just a few days ago; and Varvara Lepchenko, who got a walkover from an ill Julia Goerges.