Pope Francis decries migrant 'tragedy' at Mexico Mass
Pope Francis has decried the "tragedy" of people who are forced to migrate, as he celebrated Mass in Mexico's Ciudad Juarez city on the border with the US.
He climbed a ramp overlooking the Rio Grande that separates the city and El Paso, Texas, and laid flowers on a cross erected in memory of migrants who died trying to cross to the other side.
Earlier, he met inmates in the jail of Ciudad Juarez that was once one of the most violent cities in Mexico.
The events concluded his five-day trip.
"We cannot deny the humanitarian crisis which in recent years has meant the migration of thousands of people," the pontiff told some 300,000 people who attended the open-air Mass.
On the US side, tens of thousands watched the event on a giant screen.
"Each step, a journey laden with injustices; the enslaved, the imprisoned and extorted; so many of these brothers and sisters of ours are the consequence of trafficking in human beings," Pope Francis said.
Earlier on Wednesday, the pontiff visited a jail in Ciudad Juarez which houses about 700 inmates, 250 of them women.
Analysis - Katy Watson, BBC News, Mexico City
This trip to Ciudad Juarez was the culmination of a trip focused on meeting people on the margins.
He criticised the prison system while praying with inmates, he told the church hierarchy to leave their churches and be with their people and he urged political leaders to make Mexico a better place.
But there's one issue that is especially close to the pontiff's heart - as a Latin American and the son of immigrants, migration is a theme the Pope is keen to address.
Celebrating mass on the border with the United States went beyond Catholicism and went beyond the personal - it was a bold political move at a time when immigration is such a hotly-debated topic north of the border.
His visit was seen as a chance to give hope to the city's residents, who lived through a spate of murders and rampant drug violence which meant few dared leave their homes at night.
"The problem of security is not resolved only by incarcerating; rather, it calls us to intervene by confronting the structural and cultural causes of insecurity that impact the entire social framework," Francis told the inmates.
The pontiff's visit came just days after 49 prisoners died in a fight between rival gang members at the Topo Chico jail in the north-eastern city of Monterrey.
Mexican prisons are notoriously overcrowded and corrupt and the meeting between inmates and the pontiff is expected to draw further attention to these problems.
Pope Francis has repeatedly called on the country's leaders to make it a better place for people to live.
On Tuesday, he told young Mexicans in the violence-hit state of Michoacan "to dare to dream".
He urged them to reject a life of crime and to "know your worth".