Pope Benedict XVI has visited one of Turkey's most famous mosques in what is being seen as an attempt to mend relations with the Muslim community.
During his tour of the Blue Mosque in Istanbul, the pontiff paused in silent prayer alongside senior Muslim clerics.
It marks only the second papal visit in history to a Muslim place of worship.
Earlier, the Pope visited the nearby Hagia Sophia Museum, a site heavy with Christian and Muslim symbolism, drawing protests on the street.
The Pope spent half an hour in Hagia Sophia, a domed complex that was once a Christian centre before becoming a mosque and eventually, a museum.
Hundreds of riot police were deployed in Istanbul
Hours earlier, protesters linked to an Islamist-nationalist party had demonstrated about a kilometre away, saying the pontiff's tour was an affront to the secularism enshrined in Turkey's constitution, as well as an attempt to stake a Catholic claim to the site.
The demonstrators warned that any hint of a prayer there would be deeply offensive, but the Pope refrained from any religious gesture, such as praying or crossing himself.
The tour of the Blue Mosque - across the square from Hagia Sophia - was a last-minute addition to the schedule.
Having removed his shoes, the Pope paused for a full two minutes, eyes closed in prayer, standing side-by-side with the Mufti of Istanbul and the Imam of the Blue Mosque.
Pope Benedict's predecessor, John Paul II, is the only other pontiff to have visited a mosque, during a trip to Damascus in 2001.
ISTANBUL'S FAMOUS SITES
Blue Mosque: built in 1616 on Sultan Ahmet I's orders
John Paul II is the only other Pope to have entered a mosque
Hagia Sophia: built in 6th century as a church
converted to a mosque in 1453, a museum since 1935
The visit by Pope Benedict was seen as an attempt to repair the damage his comments on Islam in September caused across the Muslim world.
Speaking to an academic audience in Germany, the Pope quoted a Byzantine emperor who characterised Islam as a violent religion.
While the Pope insisted the remarks did not reflect his personal views, the speech was widely reported and caused anger across the Islamic world.
Since arriving in Turkey on Tuesday, he has offered wide-ranging messages of reconciliation to Muslims, including appeals for support for Turkey's bid to join the EU - which would make it the first member with a majority Muslim population.
The BBC's David Willey says the Pope has been performing a delicate balancing act between creating better relations with the Orthodox Church, while also reaching out to Muslims.
Patriarch Bartholomew and the Pope exchange the kiss of peace
The pontiff began Wednesday with a liturgical celebration by the spiritual leader of the world's Orthodox Christians, Ecumenical Patriarch Bartholomew I.
A prime reason for Pope Benedict's visit to Turkey has been to heal the centuries-old rift between the two Churches.
Patriarch Bartholomew and the Pope embraced during the service.
"The divisions which exist among Christians are a scandal to the world," the Pope said after the meeting.