Overlooking the flood lights and barbed wire that line the U.S. border, Pope Francis on Wednesday quietly prayed for the migrants who have died during their journeys to America and later said a “humanitarian crisis” was prompting people worldwide to leave for other lands.

In what amounted to a symbolic rebuke of America’s presidential campaign rhetoric on immigration — which has included calls for mass deportations of illegal workers and a huge border wall — the pope prayed atop a platform that overlooked the Rio Grande. The pontiff waved and made the sign of the cross to a crowd cheering across the river in El Paso, Tex.

The pope laid flowers at the foot of a giant cross that had been erected at the top of the ramp for the brief afternoon ceremony. Nearby, thousands who had come to the nearby Juarez fairgrounds for a Mass on the last day of the pope’s trip to Mexico observed a moment of silence.

During the Mass, the pope spoke of the thousands of immigrants who seek to cross this border and others to escape violence or find a better life.

“Each step, a journey laden with terrible injustices: the enslaved, kidnapped, extorted, many of our brothers caught in the business of human trafficking,” he said. “We cannot deny the humanitarian crisis which in recent years has meant the migration of thousands of people, whether by train or highway or on foot, crossing hundreds of kilometers through mountains, deserts and inhospitable zones.”

And while the crisis could be measured in statistics, he added, “we want instead to measure with names, stories, families.”

Maria Mijares, a 38-year-old housewife, was a member of one family divided by a border. She had stood for hours behind a metal barrier under a scorching sun, waiting for the pope to speak. More than a decade ago, the Mexican woman said, she was caught illegally crossing the Rio Grande twice and sent back. But her husband is an American citizen, now hospitalized in Texas.

“They’re denying my children the right to see their father,” she said, gesturing toward El Paso. “There shouldn’t be so many separated families or children without their parents.”

The visit to Juarez, a city that represents both migration and the drug-war violence that has tormented Mexico in recent years, marked the conclusion of the pope’s six-day trip to this country.

From the time he stepped onto the red carpet at the Mexico City airport, Francis offered pointed critiques of the failings in Mexico’s government and society, pressing his papal finger on the country’s most sensitive wounds. In front of President Enrique Peña Nieto, whose popularity has plummeted amid conflict-of-interest scandals and atrocities linked to security forces, the pope chastised Mexico’s leaders for a culture of corruption. Before the nation’s Catholic bishops, the pope warned against putting faith in the “chariots and horses of today’s pharaohs.” In a vast slum outside the capital, he spoke of the dangers of wealth and greed.

In his last stop, he broadened his focus, describing the problems of human trafficking and forced migration as global emergencies.

“No more death. No more exploitation,” the pope told the crowd in his homily.

Many church observers say that the pope, the Argentine-born son of an Italian father, finds special importance in the immigration issue, particularly at a time when large numbers of refugees are leaving countries such as Syria and Afghanistan for Europe and destinations in the Middle East. The pope last fall called on every parish or religious community in Europe to take in a refu­gee family.

On Wednesday, the pope’s visit created a festive atmosphere in this city, his face smiling from pins, T-shirts, posters and billboards that said Juarez welcomed him “with open arms.” In El Paso, thousands of people packed a football stadium to watch streaming video of the Mass.

“This is good for the border,” Amit Ghosh, a 55-year-old owner of a computer business, said as he walked through the crowds before the Mass. “He’s bringing people together. What is a two-hour Mass going to do to change millions of lives? Nothing. But he can give people hope.”

In the Republican primary race, Donald Trump and other candidates have vowed to increase border security and sharply limit the entry of Syrian refugees. Trump has threatened to ban most Muslims from visiting the United States, revoke birthright citizenship for children of unauthorized migrants, and build a multibillion-dollar wall to seal off the stream of Mexicans and Central Americans fleeing violence and poverty.

The pope’s visit here was a not-so-subtle repudiation of all that.

“The pope wanted to come to Juarez to make public the suffering of the migrants,” said the Rev. Roberto Luna, a priest in Ciudad Juarez. “The pope says that this world is a house for everyone. He’s convinced that we should treat migrants as brothers.”

Even before he arrived, Francis was blasted by Trump, who called the pontiff “a very political person.” Speaking in a Fox Business Network interview last week, Trump added that he did not think the pope “understands the danger of the open border we have with Mexico.”

“And I think Mexico got him to do it because Mexico wants to keep the border just the way it is, because they’re making a fortune and we’re losing,” Trump added.

The Rev. Federico Lombardi, the Vatican spokesman, rejected the charge.

“To suggest that the pope is an instrument of the Mexican government, no. That is very strange indeed,” he said shortly before the pontiff arrived in Ciudad Juarez, according to news agencies.

Martinez reported from Mexico City.