VATICAN CITY — Pope Francis warned against what he called a "virus of polarization" and hostility in the world targeting people of different nationalities, races or beliefs, as he led a ceremony Saturday giving the Roman Catholic Church 17 new cardinals from six continents.

The consistory ceremony in St. Peter's Basilica formally inducted the churchmen into the cardinals' ranks.

Francis used his homily to also caution the new "princes of the church," as cardinals are sometimes called, to guard against animosity creeping into the church as well, saying "we are not immune from this."

The pope spoke of "our pitiful hearts that tend to judge, divide, oppose and condemn" and cautioned somberly against those who "raise walls, build barriers and label people."

Earlier this year, when asked about the plan by Donald Trump, then a Republican U.S. presidential candidate and now president-elect, to build a wall to keep Mexicans and others from illegally entering the U.S., the pope replied that anyone advocating building walls isn't a Christian.

Francis, in a message a few days earlier to U.S. bishops, had urged them to help heal a society facing growing polarization.

On Saturday, after receiving his red hat, Mexican Cardinal Carlos Aguiar Retes, archbishop of Tlalnepantla, expressed concern about Trump's plans, including deporting large numbers of immigrants living in the U.S. illegally, soon after assuming the presidency.

"You can't divide a family. You can't divide a community. You can't divide the world," the prelate said in reply to a question by The Associated Press about Trump. The Mexican churchman added: "One thing is the election campaign. Another thing is reality."

In Saturday's homily, Francis commented on how "we see, for example, how quickly those among us with the status of the stranger, an immigrant, or a refugee, become a threat, take on the status of an enemy. An enemy because they come from a distant country, or have different customs. An enemy because of the color of their skin, their language, or social class."

He added: "The virus of polarization and animosity permeates our way of thinking, feeling and acting."

Francis also lamented the tendency to "demonize" one's opponents, "so as to have a 'sacred' justification for dismissing them."

Cardinals serve as papal advisers and someday elect popes' successors. Popes look to cardinals who share their approach to the church's mission in the world.

Indianapolis Archbishop Joseph Tobin is among the newly made cardinals. Tobin defied the governor of the U.S. state of Indiana, Mike Pence, by welcoming Syrian refugees. Tobin in January will become archbishop of Newark, New Jersey, while Pence will be installed as U.S. vice president.

Chicago Archbishop Blase Cupich, after being made a cardinal at Saturday's ceremony, said the church has a special role in trying to bring people together across the political spectrum. He noted that on Sunday, Masses are celebrated in 26 languages in his diocese.

"People feel disenfranchised" from sharing in the common good, the cardinal said in an interview with The Associated Press.

Another American in the latest crop of cardinals is Irish-born Archbishop Kevin Farrell, who led the Dallas diocese before Francis appointed him to head the Vatican office dealing with family issues.

At a post-ceremony reception, Farrell acknowledged that polarization is felt within the church, too.

"We've become gods on both sides — gods on the left, and gods on the right, and neither one of these are correct," Farrell told an AP reporter.

The clash of mentalities between the conservative camps and the so-called progressives chosen by Francis has played out publicly in recent days. Four prominent, disgruntled cardinals, including a U.S. prelate, Raymond Burke, who is one of Francis' most vocal critics, in a letter to the pope aired their doubts about his more compassionate approach to the contentious issue involving divorced Catholics. They fear his approach could sow confusion among the faithful.

Church teaching forbids divorce, and says Catholics who remarry without annulments of their earlier marriage are essentially adulterers who can't receive communion. In a document earlier this year, Francis suggested that clerics could decide case-by-case if these Catholics could receive Communion.

Farrell, asked about the tensions over the divorce issue, appeared to be open toward the pope's prescription for more compassion.

"There is no situation in life that's black and white. Anybody that's lived in this world will have encountered those situations in their personal lives," Farrell said.

The new cardinals, who pledged loyalty to the pope, come from Africa, Asia, Europe, Oceania, and North and South America.

One of them, an 88-year-old Albanian priest, Ernest Simoni, spent 18 years in prison because of his faith during the communist regime in his homeland.

Since cardinals are usually bishops already, Francis bestowed a rare honor in giving that rank to Simoni, a simple priest. When Francis visited Albania in 2014, he was brought to tears when Simoni told him how he was persecuted.

The pope's envoy to Syria is now Cardinal Mario Zenari. The Italian archbishop remarked how the bright crimson hue of the cardinals' cassocks and of the square, peaked headgear evokes the color of the blood spilled by innocent children killed in the five-year-old civil war there.

Also among the new cardinals is Archbishop Dieudonne Nzapalainga, of Bangui, Central African Republic. Last year, Francis visited Nzapalainga's country, bloodied by sectarian violence between Christian and Muslim militants.

Thirteen of the 17 new cardinals are under 80 years old and thus eligible to vote in a secret conclave for the next pope.

Francis has now appointed 44 of the 120 cardinals young enough to elect his successor. The others were named by the previous two pontiffs, John Paul II, whom Francis made a saint, and Benedict XVI, who retired in 2013, and generally reflect a more conservative leaning on church issues.

After the ceremony, the new cardinals and Francis took minibuses to the monastery on Vatican grounds where Benedict lives so they could greet him.

One of the cardinals, an 87-year-old bishop from Lesotho, Africa, was too frail to come to Rome for the ceremony.