The pontiff urged Morocco's Catholic community to avoid attempting to convert Muslims and to have good ties with people of all faiths. Pope Francis is backing Morocco's efforts to promote a moderate version of Islam.
In a joint declaration on Sunday, Pope Francis and Morocco's King Mohammed VI described Jerusalem as a "symbol of peaceful coexistence" for Christians, Jews and Muslims.
Jerusalem was "common patrimony of humanity and especially the followers of three monotheistic religions," the statement read.
"The specific multi-religious character, the spiritual dimension and the particular cultural identity of Jerusalem … must be protected and promoted," the statement added.
The spiritual leader of the world's 1.3 billion Catholics was in Morocco to promote interreligious dialogue. It was the first visit to Morocco by a pope in 34 years.
King Mohammed VI is head of a committee created by the Organization of Islamic Cooperation to protect and promote Jerusalem's religious, cultural and architectural heritage.
Last year, US President Donald Trump recognized Jerusalem as capital of Israel, causing anger across the Muslim world, especially from Palestinians that see the city as the capital of their future state.
On the second day of his trip, the pope urged the tiny Catholic community in Morocco to engage in a dialogue with Muslims in order to stamp out extremism.
"In this way, you will unmask and lay bare every attempt to exploit differences and ignorance in order to sow fear, hatred and conflict," he said on Sunday. "For we know that fear and hatred, nurtured and manipulated, destabilize our communities and leave them spiritually defenseless," he added.
Francis told a cheering crowd in Rabat that the church "grows not through proselytism but by attraction."
Morocco, a Sunni-Muslim kingdom of 36 million people, overhauled its religious policies following terrorist bombings in Casablanca in 2003 that killed 43 people.
One of the highlights of the pontiff's Morocco tour was his Saturday visit to the Mohammed VI Institute, a school of learning for imams that are exponents of a softer version of Islam.
In February, Francis visited the United Arab Emirates, where he and the imam of Cairo's Al Azhar university signed a landmark joint statement emphasizing the brotherly relation between Catholics and Muslims.