He urged the congregation to rid Mexico of drug dealer "merchants of death".
Ecatepec, with 1.6 million inhabitants, is notorious for  drug violence, kidnappings and gangland-style killings, particularly of women.
The Pope was speaking at the biggest scheduled event of his visit to Mexico.
Throughout his trip he has condemned the evils of forced emigration and drugs, urging Mexico's leaders to provide "true justice" to suffering citizens.
The Pope has described drug trafficking as a cancer that has devoured and destroyed Mexican society, while calling on the Roman Catholic Church in Mexico to do more than just condemn the problem.
Mexicans hope papal visit brings change
Thousands of admirers lined the route of the Pope's motorcade as it made its way to the huge field in Ecatepec where Sunday's Mass was celebrated.
In a final prayer in Ecatepec he urged Mexicans to turn their country into a land of opportunity "where there will be no need to emigrate in order to dream, no need to be exploited in order to work".
On Saturday he celebrated mass at the Basilica of the Virgin of Guadalupe, in front of tens of thousands of people.
On Monday, he visits Mexico's poorest and least Roman Catholic region, the indigenous state of Chiapas in the south of the country.
The following day he heads to the capital of Michoacan, a western state also scarred by drug violence.
The Pope concludes his five-day trip in Ciudad Juarez on the US border, a city which has been blighted by drug-related murders. A mass there will highlight the plight of migrants.
Pope Francis has delivered a strong denunciation of the drugs trade before an audience of 300,000 people attending an open-air mass in Ecatepec, one of poorest suburbs of Mexico City.