Outside the mosque, Ahmadinejad was welcomed by citizens holding signs and posters congratulating him on the first Iranian presidential visit since the Islamic revolution of 1979.
But the enthusiasm was not unanimously shared, as one Syrian national approached Ahmadinejad and attempted to strike him with a shoe, but was stopped by citizens and security services.
The man was removed from the area while shouting: "You're the one who ruined Syria," and was later arrested.
Protestors expressed their disapproval of the incident and stressed that objections to the presidential visit should not be performed in such manners, saying that "A guest ought to be respected."
Ahmadinejad's visit to al-Azhar,
the highest religious institution in Egypt, was also not so well received, as several radical Muslim protestors blocked his path and prevented his and his entourage's entry to the institution.
They hoisted signs condemning the visit and even demanded that Egypt's ties with Iran be severed.
Earlier on Tuesday a prominent Salafi
faction released a statement calling to bar Ahmadinejad from visiting mosques and other places important to Shiites.
The Salafis also asked to "confront Iran's president regarding the persecution of Sunnis in his country and Iran's support for Assad's regime."