RABAT, Morocco (AP) — Pope Francis praised Morocco as a model of religious moderation and migrant welcome as he kicked off a trip to the kingdom Saturday, warning that walls and fear-mongering won’t stop people from exercising their legitimate right to seek a better life elsewhere.

King Mohamed VI welcomed Francis as he arrived during an unusual rainstorm and began a 27-hour visit aimed at boosting Christian-Muslim ties and showing solidarity with Morocco’s ever-growing migrant community.

Morocco last year became the main destination for sub-Saharan African migrants seeking to reach Europe via Spain. The influx has strained the kingdom’s resources and fueled anti-migrant sentiment in Spain ahead of its April 28 general election.

After an airport greeting, the two leaders then took separate vehicles — Francis in his popemobile and the king in a convertible Mercedes — and paraded in tandem into town for a formal welcome ceremony at the complex where two of Morocco’s past monarchs are buried. Women ululated as Francis and the king walked along the promenade of the Hassan Tower complex under umbrellas.

Francis told the king that he hoped Morocco would continue to be a model of humanity, welcome and protection for migrants.

“The issue of migration will never be resolved by raising barriers, fomenting fear of others or denying assistance to those who legitimately aspire to a better life for themselves and their families,” Francis said.

Rather, he called for a change of attitude toward migrants that respects them as people, worthy of dignity and rights, and not just statistics. He said world leaders must address the economic imbalances and unrest on Earth that fuel conflicts and migration flows.

“Today’s grave migration crisis represents an urgent summons for concrete actions aimed at eliminating the causes that force many people to leave country and family behind, often only to find themselves marginalized and rejected,” he said.

It’s a message that Francis is expected to repeat later in the day when he meets migrants at a center run by the Catholic Church’s Caritas charity. Francis has made the plight of refugees a hallmark of his papacy, and has used many of his foreign visits to insist on the need to welcome them, protect them and integrate them into society.

Spain became the leading migrant entry route into Europe last year with over 57,000 unauthorized arrivals, according to the European Union. Morocco became the main departure point for migrants in smugglers’ unseaworthy boats after Italy essentially closed its borders to migrants leaving Libya.

Around 2,300 people died crossing the Mediterranean Sea last year and over 300 have already died this year on the dangerous journey, according to the International Organization for Migration.

Francis opened his remarks to the king by praising Morocco’s tradition of interfaith coexistence and its efforts to promote a moderate form of Islam.

Morocco, a Sunni Muslim kingdom of 36 million, reformed its religious policies and education to limit the spread of fundamentalism in 2004, following terrorist bombings in Casablanca in 2003 that killed 43 people.

Key to that effort has been the Mohammed VI Institute, a school of learning for imams that teaches a moderate Islam and exports it via preachers to Africa, the Middle East and Europe. Francis was visiting the institute later Saturday.

Francis praised the school, saying it “seeks to provide effective and sound training to combat all forms of extremism, which so often lead to violence and terrorism, and which in any event, constitute an offense against religion and against God himself.”

The king said education was the key to fighting radicalism — not military crackdowns.

“What all terrorists have in common is not religion, but rather ignorance of religion,” he said.

The trip follows Francis’ February visit to the United Arab Emirates, where the pope and the imam of Cairo’s Al Azhar, the seat of Sunni learning, signed a landmark joint statement establishing the relationship between Catholics and Muslims as brothers, with a common mission to promote peace.

The “Human Fraternity” document outlines a shared set of values and principles common to Christians and Muslims, focusing on the dignity of every person and a rejection of violence committed in God’s name.

Muslims, Christians and Jews have long lived peacefully in Morocco, even though Catholics are a tiny minority of about 23,000.

Francis will minister to them on Sunday when he celebrates Mass in Rabat’s sports stadium, before returning to Rome.