Egypt's state-run media said the incident occurred late Tuesday as Ahmadinejad left a mosque in Cairo. Four Egyptians and a Syrian waved their shoes -- considered a sign of disrespect in eastern culture -- to protest Iran's support for the Syrian President Bashar Assad, the reports said.
Video released by a Turkish news outlet indicated a shoe struck the Iranian president's head.
The Gulf News said the five arrested chanted anti-Ahmadinejad slogans as they were taken to a nearby police station for questioning.
Ahmadinejad is the first Iranian head of state to visit Egypt in more than three decades after Tehran cut diplomatic ties with Cairo in 1980 to protest Egypt's peace treaty with Israel. The situation between the two regional powers has improved since Egyptian President Hosni Mubarak was ousted nearly two years ago.
Because Iran is predominantly Shiite, Ahmadinejad's visit has angered Egypt's hardline Sunnis, in the majority in Egypt, Gulf News said.
"He must not be allowed to visit places claimed by Shiites," a Salafist organization said in a statement.