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 border walls and fear-mongering won't stop people from exercising their rights to seek a better life elsewhere.

King Mohamed VI welcomed Francis as he arrived during an unusual rainstorm and began a visit aimed at boosting Christian-Muslim ties and showing solidarity with Morocco's 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 the European Union nation's April 28 general election.

Francis met with some of Morocco's newest arrivals and assured them: "You are not the marginalized. You are at the center of the church's heart."

After an airport greeting, the king and pope took separate vehicles — Francis in his popemobile and the king in a Mercedes with a retracted roof — and paraded in tandem into town for a formal welcome ceremony at the complex where two of Morocco's former 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.

Later Saturday, Francis repeated the sentiment during an encounter with migrants from Nigeria, Guinea, Cameroon and other countries, telling them they deserved to be welcomed, protected and integrated into their new homes. He called for expanded legal channels for migration and for protections for the most vulnerable, regardless of their refugee status.

"This shared commitment is needed in order to avoid presenting new opportunities to those merchants of the human flesh who exploit the dreams and needs of migrants," he told the gathering at the Catholic-run Caritas charity.

Many sub-Saharan Africans in Morocco head north to cross the Strait of Gibraltar to Spain or climb over high fences to reach Spain's North African enclaves of Ceuta and Melilla. Those who make it across the 6-meter (20-foot) fences end up in crowded migrant centers from which they are eventually repatriated or let go.

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, after Italy essentially closed its borders to migrants leaving Libya. Nearly 2,300 people died crossing the Mediterranean Sea last year and over 310 have already died this year on the dangerous journey, according to the International Organization for Migration.

The EU agreed this summer to give Morocco $275 million to halt flows of illegal migrants, pushing the country to take a more violent approach in stopping them from leaving for Europe, activists say.

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 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."

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 two leaders visited the institute together, where they heard from students and were treated to a stunning and symbolic vocal and orchestral performance that opened with a Muslim call to prayer, and blended Christian and Hebrew musical traditions.

Nigerian microbiologist Hindu Usman told the pope and king that when she graduates and returns home, she hopes to work to deter religious extremism and promote coexistence with Christians, Muslims and people of other faiths. Her education, she said, made her able to "argue and convince others that religion is for peace and goodness ... that women are equal with men in their rights."

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 Catholics and Muslims as brothers with a common mission to promote peace. The "Human Fraternity" document outlines a shared set of principles, focusing on the dignity of every person and rejecting violence committed in God's name.

Muslims, Christians, and Jews have long lived peacefully in Morocco, with Catholics a tiny minority of about 23,000. Francis will minister to them on Sunday when he celebrates Mass in Rabat's sports stadium.