Security guards have seized a man who tried to hit Iranian President Mahmoud Ahmadinejad with a shoe as he visited a mosque in the Egyptian capital Cairo.
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.
Mr 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 Organisation of Islamic Co-operation, a loose grouping of 57 mainly Muslim countries.
Egypt's new Islamist President, Mohammed 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.
Warning to Iran
Tuesday's incident occurred as Mr 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.
Watch the video:
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 Egypt's top Sunni cleric, Sheikh Ahmed al-Tayeb, warned Mr Ahmadinejad over Iran's approach to Sunni Arab nations.
Mr Tayyeb, the grand sheikh of al-Azhar, Sunni Islam's leading authority, Iran should not interfere in the internal affairs of Gulf states and seek the "extension of Shia reach".
He singled out Bahrain, where Iran has been accused by the Sunni monarchy of stirring up unrest among the island's Shia majority.