Ahmadinejad
Iran's President Mahmoud Ahmadinejad leaves after visiting the Al-Hussein mosque in old Cairo on Feb. 5, 2013 REUTERS

Iranian President Mahmoud Ahmadinejad’s visit to Cairo took an unpleasant turn Tuesday evening when he was almost struck by a shoe that a man threw at him.

The incident occurred as Ahmadinejad was leaving Cairo's Al-Hussein mosque.

It was not clear what the motive behind the attack was, but Turkey’s Anadolu Agency, which captured the attack on video, reported that the bearded perpetrator was a Syrian who, likely referring to Iran’s support for Syrian President Bashar Al-Assad, shouted, “You killed our brothers!”

The video shows a man straining forward in the crowd with a shoe in his hand and shouting “coward” as he throws it.

The attacker was reportedly arrested by the police after he was removed from the scene by security guards.

Earlier on Tuesday the Iranian president was put on the spot when Egypt’s top cleric told him not to interfere in the affairs of Bahrain or other Gulf states and to uphold the rights of his Shia-dominated country's Sunni population.

Ahmed al-Tayyeb, the grand imam of Cairo's Al-Azhar, Sunni Islam's leading authority, denounced Iran for its role in what the cleric called the “spread of Shiism in Sunni lands,” according to a statement released by Al-Azhar.

Iran has been accused by Bahrain’s Sunni monarchy of stirring up unrest among the island's Shia majority. In October, Bahrain summoned an Iranian envoy to protest Tehran's support for stirring up the protests against the monarchy.

In a news conference following his meeting with Tayeb, Ahmadinejad said he "came from Iran to say that Egypt and the Egyptian people have their place in the heart of the Iranian people,” Egypt’s Al-Ahram newspaper reported.

But senior Al-Azhar cleric Hassan al-Shafie, who spoke after Ahmadinejad, criticized “some Shiites” in the presence of the president, who appeared ill at ease.

"The discussions were frank," Shafie said about Ahmadinejad’s meeting with Tayeb.

Ahmadinejad is the first Iranian president to visit Egypt since the Islamic revolution in 1979. The visit follows one to Tehran by Egyptian President Mohamed Morsi for a summit of the Non-Aligned Movement in August. Then the two leaders agreed to re-establish ties.

In the past, Egypt, a predominantly Sunni nation, had considered Shia-dominated Iran as a political rival in the Middle East’s political landscape.