Iran's President Mahmoud Ahmadinejad is in Egypt on the first trip by an Iranian head of state since the 1979 revolution.

The visit underlines the thaw in relations since Egyptians elected an Islamist head of state.

President Mohammed Mursi, the Muslim Brotherhood politician elected in June, kissed Mr Ahmadinejad as he disembarked from his plane at Cairo airport.

The leaders walked down a red carpet, with Mr Ahmadinejad smiling as he shook hands with waiting dignitaries.

He is visiting Cairo to attend an Islamic summit that begins tomorrow.

Mr Ahmadinejad is due to meet 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, 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," Mr 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 Gaza, 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," Mr Ahmadinejad said.

Analysts doubt that the historic changes that brought Mr 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.

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 Mr 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.

Mr Mursi wants to preserve ties with the United States, the source of $1.3bn in aid each year to the influential Egyptian military.

His 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.

Mr Ahmadinejad's visit to Egypt follows Mr 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 Mr Ahmadinejad at his offices in 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.