Obama said he is optimistic that the U.S. will change its patchwork of immigration laws. With about 6 million Mexicans illegally in the United States, the issue resonates deeply in Mexico, which also has seen deportations of its citizens from the U.S. rise dramatically under Obama.
Underlying Obama's visit was his desire to persuade the U.S. public and lawmakers that Mexico no longer poses the illegal immigration threat it once did.
"The long-term solution to the challenge of illegal immigration is a growing and prosperous Mexico that creates more jobs and opportunities for young people here," said Obama.
To that end, he called for improving the growing trade relationship between the two countries. Mexico is the second-largest export market for U.S. goods and services. The U.S. also buys more Mexican exports than any other country. Still, the reality of Mexico's economic surge is perhaps not as rosy as Obama portrayed it.
While Mexico's economy has grown, it has yet to trickle down to average workers. Huge poverty rates held steady between late 2006 and 2010, the most recent year for which government statistics are available. Between 40 percent and 50 percent of the population of 112 million Mexicans live in poverty, earning less than $100 a month.
Obama also cited Mexico's healthy manufacturing sector as an example of the country's "impressive progress," with new factories turning out TVs and automobiles for foreign markets. But some of that growth is due to the fact that wages largely have stagnated, while China's have risen, making Mexico more of a low-wage paradise.
Mexico's economy grew by about 1 percent in the first three months of the year and the country isn't creating anywhere near the million jobs annually it needs to employ all the young people entering its workforce.
Obama spoke on the second day of his Mexico City visit, peppering his remarks with Spanish phrases, including that he was "entre amigos" or "among friends." He concluded with "Viva Mexico. Viva los Estados Unidos. Que Dios los bendiga" or "Long live Mexico. Long live the United States. May God bless them."
After the speech, he was heading to Costa Rica, where he planned to deliver a blunter message to Central American leaders struggling with weak economies and drug violence. Obama was to meet with Costa Rican President Laura Chinchilla before joining leaders from the Central American Integration system. The regional network also includes the leaders of Belize, El Salvador, Guatemala, Honduras, Nicaragua and Panama.
The U.S. view of the region is that its pervasive violence and security weaknesses are holding back economic growth, and that with fewer Mexicans crossing the border illegally, the rest of the region has become the main source of illegal immigration into the United States.
As a result, Obama is expected to call for stepped up security cooperation, regional economic integration and improvements in human rights and democratic reforms.
"We want to make sure that our hemisphere is more effectively integrated to improve the economy and security of all peoples," Obama said Thursday. "There is a whole range of opportunities, and that will be the purpose of this trip."
Friday's speech came as Obama's popularity in Mexico has risen in recent years and as views of the United States also improve. A Pew Research Center poll in March found that two-thirds of Mexicans have a favorable opinion of the U.S., compared with 44 percent in 2010. About half of Mexicans have confidence that Obama will do the right thing on world affairs, up from 38 percent in 2011.
Still, dozens of migrant families deported from the U.S. even though their children were born there rallied outside the U.S. Embassy before Obama's arrival Thursday. "Obama, don't deport my Mama," one sign said. So far, the Obama administration has deported more than 1.6 million people.
For all the attention to commerce and trade, the visit to Mexico less than two days long was not designed for major breakthroughs or new initiatives. Indeed, on one of the top economic pacts before them, Obama and Mexican President Enrique Pena Nieto merely reaffirmed a goal to conclude negotiations this year on a Trans-Pacific Partnership, an Asia-Pacific trading bloc that is key to Obama's efforts to boost exports to Asia.
Both men, however, did announce a new partnership to build on the business relationship with closer cooperation between top officials in Mexico and the U.S., including Vice President Joe Biden.
At a joint news conference Thursday, Obama and Pena Nieto carefully sidestepped potential trouble spots. Obama steered clear of commenting on Pena Nieto's decision to end the broad access that U.S. security agencies have had in Mexico to combat drug trafficking. The decision has alarmed some U.S. officials.
"President Pena Nieto and his team are organizing a vision about how they can most efficiently and effectively address these issues," Obama said. "And we will interact with them in ways that are appropriate, respecting that ultimately Mexico has to deal with its problems internally and we have to deal with ours as well."
For his part, Pena Nieto declined to be drawn into the immigration debate in Washington, a top priority for Obama but one that is at a delicate stage in Congress. Asked to comment, the Mexican president merely acknowledged the efforts under way in Congress.
"Mexico understands that this is a domestic affair for the U.S. and we wish you the best push that you're giving to immigration," he said.
Likewise, Pena Nieto demurred when asked to react to the failure of the U.S. Senate to pass gun control legislation, including an expanded background check for firearms buyers, even though many guns obtained illegally in the U.S. end up in the hands of drug dealers in Mexico.
He said he agreed with Obama's campaign to stem gun violence, but added: "This is a domestic issue in the United States."
Obama vowed to keep pressing for gun legislation, saying: "We recognize we've got obligations when it comes to guns that are oftentimes being shipped down south and contributing to violence here in Mexico."