Mexicans take part in an open-air Mass celebrated by Pope Francis in Ecatepec, near Mexico City, on Sunday. (Alfredo Estrella/AFP/Getty Images)

On the crime-ridden outskirts of Mexico City, Pope Francis urged Mexicans to avoid the temptations of wealth and corruption, deepening his warnings against materialism and selfishness in a country suffering from the ills of drug-trafficking and violence.

Francis, on his first visit to Mexico, an overwhelmingly Catholic country, celebrated a morning Mass before a quarter-million people on a field in Ecatepec, a working-class area north of Mexico City that has been one of the centers of kidnapping and killing in recent years. Arriving by helicopter from Mexico City, the pontiff led the outdoor ceremony from a covered stage, under a hazy sun, delivering an extended warning against wealth, vanity and pride.

Taking goods “that have been given to everyone and using them only for me” is to take bread from someone else’s toil “or even their own life,” he said.

“That wealth is bread that tastes of pain, bitterness, suffering. That is the bread that a family or a corrupt society gives its own children,” he said.

The pope, in his homily, inveighed against vanity and pride, extending the message he delivered at the start of the weekend, when he warned President Enrique Peña Nieto and his cabinet against the evils of corruption. Francis cautioned Mexican youths over the corrosive power of drug-trafficking and told bishops to be servants to the poor and not to the wealthy and powerful.

Francis on Sunday described Mexico as a land of opportunity, “where it is not necessary to emigrate to dream, where it’s not necessary to be exploited to work, where it’s not necessary to make of the desperation and poverty of many into the opportunism of the few.”

“It’s a land where men and women, youth and children, don’t have to cry,” the pope went on, gathering steam, “or end up destroyed in the hands of death traffickers.”

His message startled some observers who didn’t expect him to so directly confront Mexico’s ills during his six-day visit. The banner headline on the front page of El Universal’s Sunday newspaper was: “Pope criticizes corruption and narcos.”

“It’s a very strong criticism,” Bernardo Barranco, a sociologist who studies religion, said. “He questions the political class in a manner that’s gentle but also direct and forceful, rejecting the politics in the country, because this political class is far from the common good.”

After the Mass, Francis planned to visit a pediatric hospital to meet with sick children. On Monday, he is headed to the southern state of Chiapas, one of the poorest in the country, where Central American migrants are flooding through on their way to the United States.

Before leaving Ecatepec on Sunday, the pope told the massive crowd, “Don’t forget to pray for me.”

Gabriela Martinez contributed to this report.