President Mohamed 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, Mr Ahmadinejad smiling as he greeted waiting dignitaries.
Visiting Cairo to attend an Islamic summit that begins today, the president of the Shi'ite Islamist republic was due to meet 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 autocrat who preserved Egypt's peace treaty with Israel during his 30 years in power and deepened ties between Cairo and the West.
Mr Ahmadinejad said in an interview with Al Mayadeen, a Beirut-based TV station, on the eve of his visit he wanted to visit the Gaza Strip, the Palestinian territory that 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," he said.
Analysts doubt that the changes that brought Mr Mursi to power will result in a full restoration of diplomatic ties between the two countries whose relations were broken off after the Iranian revolution and Egypt's peace treaty with Israel in 1979.
Egypt is concerned by Iran's support for Syrian President Bashar al Assad, trying to crush an uprising inspired by the revolt that deposed Mubarak.