Pope Francis has called on Moroccans to fight fanaticism during a visit to promote inter-faith dialogue.
He was met at the airport by King Mohammed VI and driven to the capital Rabat, where he gave a speech.
The pontiff is to meet migrants and Muslim leaders, and hold a Mass for the country’s small Roman Catholic community this weekend.
The Vatican considers the papal visit a continuation of last month’s historic trip to the United Arab Emirates.
Islam is the state religion in Morocco.
To a crowd of thousands, Pope Francis said it was “essential to oppose fanaticism” and for the faithful to “live as brothers”.
He defended “freedom of conscience” and “religious freedom” as fundamental for human dignity, and said it was “necessary” to make the “appropriate preparations of future religious guides”.
Since 2015, 1,600 young Moroccans are estimated to have been radicalised and joined jihadists fighting for the Islamic State group.
King Mohammed said the key to tackling radicalisation of young people was to increase religious education.
The spiritual leader of the world’s 1.3 billion Catholics was invited to the North African nation by its king, Moroccan authorities said, as part of the “development of inter-religious dialogue”.
Moroccan law guarantees freedom to worship.
But Christians – who make up less than 1% of the country’s 33 million people say they are not allowed to worship openly and face discrimination.
Under the penal code, you can be put in prison for trying to convert a Muslim to Christianity.