MEXICO CITY — President Obama, speaking to an enthusiastic crowd of young people here, on Friday declared a new era in relations with Mexico that will focus on strengthening the countries’ economic ties and that will play down the battle against drug gangs that has dominated the discourse for several years.

Hours after a private dinner with President Enrique Peña Nieto of Mexico, who has made an overhaul of laws to foster economic growth the highlight of his five-month-old term, Mr. Obama urged Americans to look past stereotypes of Mexican violence and despair, and embrace the country’s strengthening democracy and economic health.

“We agree that the relationship between our nations must be defined not by the threats that we face, but by the prosperity and the opportunity that we can create together,” Mr. Obama said to vigorous applause before an audience of high school and college students at the National Anthropology Museum.

After suggesting a few days ago that security relations between the United States and Mexico could be better, Mr. Obama hardly mentioned the subject in his speech or in earlier remarks on Thursday, a sign the topic has given American officials plenty of headaches. Thousands of people have been killed in battles between Mexican drug gangs and the police and military, while the flow of cocaine and marijuana flourishes.