Video of the incident shows a man shouting “coward” as he strikes out.
It is not clear what the motive was – some reports suggested it was against Iran’s support for Syria’s government.
Mahmoud Ahmadinejad is the first Iran leader to visit Egypt since the 1979 Islamic revolution. Showing the sole of a shoe is a grave insult in the Arab world.
The Iranian leader is attending a summit of the Organization of Islamic Co-operation, a loose grouping of 57 mainly Muslim countries.
Egypt’s new Islamist President Mohamed Morsi has sought to follow an independent path on foreign policy and travelled to Tehran soon after coming to power last year.
However, so far his talks with Iran about its policy towards Syria have had little impact.
Tuesday’s incident occurred as Mahmoud Ahmadinejad was leaving Cairo’s Al-Hussein mosque.
Video released by Turkish news agency Anadolu shows a man straining forward in the crowd with a shoe in his hand, striking out several times.
A witness quoted by AFP news agency said the man had booed and pushed a bodyguard.
The man, believed to be Syrian because of his accent, was reportedly arrested by police after being restrained by security guards.
While the motive for the attack was unclear, the visit of the president of solidly Shia Muslim Iran has caused some friction
in mainly Sunni Muslim Egypt.
Outside the mosque, four youths waved placards scrawled with slogans against Iran over its support for Syrian President Bashar al-Assad.
There was embarrassment earlier on Wednesday when one of Egypt’s top Sunni Muslim clerics, Ahmed al-Tayyeb, publicly criticized Shia Islam at a meeting with Mahmoud Ahmadinejad.
Ahmed al-Tayyeb, the grand imam of al-Azhar, Sunni Islam’s highest seat of learning, told the Iranian leader not to interfere in the internal affairs of Sunni states and condemned the “spread of Shia-ism in Sunni lands”.
He singled out Bahrain, where Iran is accused of stirring up unrest among the Shia majority against the Sunni monarchy.
E2vW7Eq2ZRgImage source: Wikimedia Commons President-elect Donald Trump celebrated his election victory at the Ultimate Fighting…
Millions of voters across the US chose to return Donald Trump to the White House…
Donald Trump declares victory in the US election as he addresses jubilant supporters in Florida.…
Stocks around the world are rising as Donald Trump appears to be on the cusp…
Donald Trump has won Pennsylvania, North Carolina and Georgia and taken a lead over Kamala…
Quincy Jones, the celebrated musician and producer who worked with Michael Jackson, Frank Sinatra, Ray…