Pope Francis has wrapped up his three-day visit to Turkey after a liturgy alongside the spiritual leader of the world's Orthodox Christians and a meeting with young refugees who have fled Syria, Iraq and other conflict zones.

Francis and Ecumenical Patriarch Bartholomew I issued a joint declaration at the end of their meeting on Sunday, which falls on an important feast day for the Orthodox Church.

The Catholic and Orthodox churches split in 1054 over differences on the primacy of the papacy, and there was a time when patriarchs had to kiss popes' feet.

At the end of a joint prayer service on Saturday, the second day of his visit, Francis bowed to Bartholomew and asked for his blessing, a remarkable display of papal deference to an Orthodox patriarch that underscored Francis' hope to end the schism.

Also on Saturday, Francis took part in a Muslim prayer alongside the grand mufti of Istanbul.

Francis stood with his head bowed and hands clasped in front of him in a two minutes of silent prayer inside the 17th-century Sultan Ahmet Mosque, aiming to show respect for Islam and encourage stronger ties between the two faiths.

"May God accept it," Rahmi Yaran, the grand mufti of Istanbul, told Francis at the end of the prayer.

Earlier Yaran gave Francis a tour of the mosque, which is famed for its elaborate blue tiles and cascading domes and better known as the Blue Mosque.

Francis then visited the nearby Haghia Sofia, which was the main Byzantine church in Constantinople - present-day Istanbul - before being turned into a mosque following the Muslim conquest of the city in 1453.

The Haghia Sophia is now museum, although some Islamic groups want it to be converted back into a mosque.

A few dozen well-wishers outside Haghia Sophia waved a combination of the Turkish and the flag of the Holy See.

In meetings with Turkish leaders in the capital Ankara on Friday, Francis urged Muslim leaders to condemn the "barbaric violence" being committed in Islam's name against religious minorities in Iraq and Syria.

He reaffirmed that military force was justified to halt the Islamic State of Iraq and the Levant (ISIL) group's advance, and called for greater dialogue among Christians, Muslims and people of all faiths to end fundamentalism.

Source: Al Jazeera and agencies