* Visit is first by Iranian leader since 1979 revolution
* Mursi walks red carpet with Ahmadinejad at airport
* Ahmadinejad sees closer ties changing Middle East politics
By Tom Perry
CAIRO, Feb 5 (Reuters) - President Mahmoud Ahmadinejad arrived in Egypt on Tuesday on the first trip by an Iranian head of state since the 1979 revolution, underlining the thaw in relations since Egyptians elected an Islamist head of state.
President Mohamed Mursi, the Muslim Brotherhood politician elected in June, kissed Ahmadinejad as he disembarked from his plane at Cairo airport. The leaders walked down a red carpet, Ahmadinejad smiling as he shook hands with waiting dignitaries.
Visiting Cairo to attend an Islamic summit that begins on Wednesday, the president of the Shi'ite Islamist republic is due to meet later on Tuesday with the grand sheikh of al-Azhar, one of the oldest seats of learning in the Sunni world.
Such a visit would have been unthinkable during the rule of Hosni Mubarak, the military-backed autocrat who preserved Egypt's peace treaty with Israel during his 30 years in power and deepened ties between Cairo and the West.
"The political geography of the region will change if Iran and Egypt take a unified position on the Palestinian question," Ahmadinejad said in an interview with Al Mayadeen, a Beirut-based TV station, on the eve of his visit.
He said he wanted to visit the Gaza Strip, the Palestinian territory which neighbours Egypt to the east and is run by the Islamist movement Hamas. "If they allow it, I would go to Gaza to visit the people," Ahmadinejad said.
Analysts doubt that the historic changes that brought Mursi to power in Egypt will result in a full restoration of diplomatic ties between states whose relations were broken off in 1980 - a year after the Iranian revolution and the conclusion of Egypt's peace treaty with Israel.
OBSTACLES TO FULL TIES
Egypt is concerned by Iran's support for Syrian President Bashar al-Assad, who is trying to crush an uprising inspired by the revolt that swept Mubarak from power two years ago. Egypt's overwhelmingly Sunni Muslim population is broadly supportive of the uprising against Assad's Alawite-led administration.
The Mursi administration also wants to safeguard relations with Gulf Arab states that are supporting Cairo's battered state finances and are deeply suspicious of Iran. Mursi wants to preserve ties with the United States, the source of $1.3 billion in aid each year to the influential Egyptian military.
Mursi's government has established close ties with Hamas, a movement backed by Iran and shunned by the West because of its hostility to Israel, but its priority is addressing Egypt's deep economic problems.
"The restoration of full relations with Iran in this period is difficult, despite the warmth in ties ... because of many problems including the Syrian crisis and Cairo's links with the Gulf states, Israel and the United States," said one former Egyptian diplomat.
Ahmadinejad's visit to Egypt follows Mursi's visit to Iran in August for a summit of the Non-Aligned Movement.
Sheikh Ahmed al-Tayeb, head of the 1,000-year-old al-Azhar mosque and university, will meet Ahmadinejad at his offices in mediaeval Islamic Cairo, al-Azhar's media office said.
Iranian Foreign Minister Ali Akbar Salehi stressed the importance of Muslim unity when he met Sheikh al-Tayeb at al-Azhar last month.
Egypt and Iran have taken opposite courses since the late 1970s. Egypt, under Mubarak's predecessor Anwar Sadat, concluded a peace treaty with Israel in 1979 and became a close ally of the United States and Europe. Iran from 1979 turned into a centre of opposition to Western influence in the Middle East.
Symbolically, Iran named a street in Tehran after the Islamist who led the 1981 assassination of Sadat.
Egypt gave asylum and a state funeral to Iran's exiled Shah Reza Pahlavi, who was overthrown by the 1979 Iranian revolution. He is buried in a medieval Cairo mosque alongside his ex-brother-in-law, Egypt's last king, Farouk. (Additional reporting by Ayman Samir; Editing by Andrew Roche)