Egypt's Islamist President-elect Mohammed Mursi says he wants to expand ties with Iran to create a strategic balance in the region.
Diplomatic relations between the two countries have been severed for more than 30 years, but both sides have signalled a shift in policy since former president Hosni Mubarak was overthrown last year in a popular uprising.
Mohammed Mursi's victory over former general Ahmed Shafik in Egypt's first free presidential election has been hailed by Iran as the final phase of an "Islamic awakening".
Mainly Sunni Muslim Egypt and predominantly Shi'ite Iran are among the biggest and most influential countries in the Middle East, but they have had no formal ties since 1980, following Iran's Islamic revolution and Egypt's recognition of Israel.
Mr Mursi of the Muslim Brotherhood won the presidential election in Egypt by a margin of less than 900,000 votes.
Mr Mursi won 51.7% of the vote, beating former Prime Minister Ahmed Shafiq by a margin of less than 900,000 votes.
The annnouncement by the head of the electoral commission, Farouq Sultan, on national television on Sunday sparked wild celebrations in Tahrir Square, where huge cheers erupted.
Across Cairo, cars sounded their horns amid crowds chanting "Mursi, Mursi".
The armed forces were on high alert ahead of the announcement due to fears of violence breaking out.
Supporters of Mr Shafiq, who were holding a rally in the capital's northern suburb of Nasser City, were stunned by the result.
There was screaming and crying and people were seen holding their heads in despair.
The electoral commission said Mr Mursi won 13,230,131 votes (51.73%), compared with Mr Shafiq's total of 12,347,380, or 48.27%.
The turnout in last weekend's voting was 51.58%.
Mr Mursi, 60, won the first round ballot in May with almost a quarter of the vote. He has pledged to form an inclusive government.
The Supreme Council of Armed Forces will retain control of the army. Mr Mursi has said he will respect international treaties.
Mr Mursi replaces President Hosni Mubarak who was deposed in February last year.
Mr Mursi on Sunday hailed a "historic day" for the nation and said he would be a president for all Egyptians.
He thanked God and "the blood, tears and sacrifices" of his fellow countrymen.
"Today I am a president for all Egyptians, wherever they may be," he said.
"Thanks to our unity and our love for each other, we will able to make a respectable future for ourselves."
''Egypt, our beloved homeland, needs our unity," he said in a speech broadcast by state television on Sunday.
"The revolution continues until all its goals are achieved. Together we continue the journey."
He saluted the "martyrs of the revolution". But he also praised the army and police, who many Egyptians see as playing negative roles over the past year.
Mr Mursi also promised to preserve all international treaties.
"We come in peace," he said.
One of the issues Mr Mursi will have to address is the Muslim Brotherhood party's relationship with the interim military council that recently curbed the powers of the presidency by decree.
The BBC reports he resigned on Sunday from his positions within the organisation - including his role as chairman of its Freedom & Justice Party - as he had pledged to do in the event of his victory.
The Muslim Brotherhood was founded by Hassan al-Banna in the 1920s.
It has influenced Islamist movements around the world with its model of political activism combined with Islamic charity work.
The Brotherhood was banned after a failed attempt to assassinate President Gamal Abdul Nasser in 1954.
The BBC reports it became the main opposition force in Egypt in 2000, when its members won 17 seats in the People's Assembly.
Five years later, the organisation and its allies won 20% of the seats.