CAIRO (AP) -- President Mahmoud Ahmadinejad's visit to Cairo on Tuesday, the first by an Iranian leader in more than three decades, highlights efforts by Egypt's Islamist leader to thaw long frigid ties between the two regional heavyweights.
Although the official welcome was warm, there was unscripted discord from Sunni protesters angry over Iran's support for the regime of Syrian President Bashar Assad, as well as decades of sectarian animosity between Shiite-led Iran and the region's Sunni majority.
At one point, Ahmadinejad was forced to flee an ancient mosque in downtown Cairo after a Syrian protester took off his shoes and threw them at him.
Later, anti-Iranian protesters raised their shoes up while blocking the main gates to Al-Azhar, the Sunni world's most prestigious religious institution, where Egypt's most prominent cleric chided Ahmadinejad for interfering in the affairs of Sunni nations.
The protests illustrate the limits to how far and how quickly Egypt's Islamist President Mohammed Morsi can go in reaching out to Iran: His Sunni allies at home view mainly Shiite Iran as a bitter rival, and Cairo can't afford to alienate Washington and Gulf Arab states who seek to isolate Tehran.
The three-day visit, centered around an Islamic summit, was an attempt by Morsi to strike an independent foreign policy and reassert Egypt's historic regional leadership role following the ouster of Hosni Mubarak, a close U.S. ally who shared Washington's deep suspicions of Tehran. Such a visit by an Iranian leader would have been unthinkable under Mubarak.
Morsi gave Ahmadinejad a red-carpet welcome on the tarmac at Cairo airport, shaking his hand, hugging and exchanging a kiss on each check.
The two leaders then sat down for a 20-minute talk that focused on the civil war in Syria, security officials said, speaking on condition of anonymity because they were not authorized to brief the media. Iran is Damascus' closest regional ally, while Egypt is among those that have called on Assad to step down.
Still, the chasm inherited from 34 years of bitter relations and the rift between overwhelmingly Sunni Egypt and Iran's Shiite leadership were on display.
Sunni-Shiite tensions dominated talks between Ahmadinejad and Egypt's most prominent cleric, Sheik Ahmed el-Tayeb, who upbraided the Iranian leader on a string of issues and warned against Iranian interference in Gulf nations, particularly Bahrain, where the ruling Sunni minority has faced protests by the Shiite majority.
El-Tayeb said attempts to spread Shiite Islam in mainly Sunni Arab nations were unacceptable and called for a halt to bloodshed in Syria, where Tehran's ally Assad has been battling rebels, according to a statement by Al-Azhar about the meeting.
The Sunni cleric also demanded that Ahmadinejad speak out against insults hurled at the first caliphs who succeeded the Prophet Muhammad and other figures close to the prophet in the 7th century. Those figures are widely resented among Shiites because they are seen as having pushed aside Ali, the prophet's son-in-law, who Shiites consider his rightful successor. The dispute over succession is at the root of the centuries-old split between Islam's Shiite and Sunni sects.
The meeting was "tense," acknowledged an aide to the sheik, Hussein al-Shafie, speaking at a news conference with Ahmadinejad that el-Tayeb did not attend.
Earlier, a Syrian man was arrested by police after he hurled his shoes at the Iranian leader outside the ancient al-Hussein mosque in downtown Cairo, according to security officials, who spoke on condition of anonymity because they were not authorized to speak to the media.
Ahmadinejad's visit came nearly six months after another historic first: a trip by Morsi to Tehran, where disdain for Egypt led the ruling regime to name one of its streets after the ringleader of the assassination team that gunned down President Anwar Sadat in 1981.
Egypt was once closely allied to Iran's former ruling shah. The two countries severed relations after the 1979 Islamic Revolution brought a clerical rule to power in Iran and Egypt offered refuge to the deposed shah. Ahmadinejad's visit to Al-Azhar brought him not far from a grandiose Cairo mosque where the shah -- despised by Iran's clerical rulers -- is buried.
Relations further deteriorated after Egypt's peace treaty with Israel.
"For the first time, we are witnessing breaking of ice between the two countries," said political analyst Rafaat Sayed Ahmed.
Ultraconservative Islamists known as Salafis, who view Morsi as too pragmatic and compromising but ally with him in the face of secular opposition, see Iran as Sunni Islam's greatest enemy. Salafi clerics often rail against Shiites and Iran in their sermons.