"We didn't win everything, but we were able to claim a victory with there being no tariffs," said chief negotiator Marcelo Ebrard, Mexico's foreign affairs secretary, on June 9.
The two neighbors have been at odds since United States President Donald Trump on May 30 threatened to hit all Mexican imports with steadily rising tariffs unless Mexico successfully halted the northward flow of Central American migrants fleeing extreme poverty and violence through Mexico toward the United States.
Approximately 80% of Mexican exports are destined for the United States. Tariffs would have devastated Mexico's economy.
To keep its goods untaxed, Mexico had to convince President Trump that it was serious about stopping migration. After a week of frantic negotiations, Mexico said it would deploy up to 6,000 National Guard troops to its southern border with Guatemala to stop migrants from entering Mexico.
As part of the agreement, a Trump administration program known as "Remain in Mexico," which forces some migrants to wait in Mexico while their asylum claims are processed in the U.S., will also be expanded.
At a June 8 rally "for the dignity of Mexico and friendship with the U.S." held in the border city of Tijuana, Lopez Obrador pledged that Mexico will reinforce its southern border while still "applying the law and respecting the human rights" of migrants.
Ebrard added at the rally that Mexico had emerged from a near trade war with its "dignity intact."
Many Mexican lawmakers, including allies of the president, have expressed outrage that their immigration policy is now bound by an "immoral and unacceptable" deal that effectively turns Mexico itself into Trump's border wall.
It also violates the Mexican Constitution and international law.
According to international refugee law asylum-seekers with demonstrable fear of persecution in their home countries are entitled to seek protection in the place of their choosing. Mexican law goes further. As of 2011, legitimate asylum-seekers are entitled not just to seek but to be granted asylum in Mexico.
Trump's economic threats against Mexico may not even have been legal. Both the current North American Free Trade Agreement and the newly signed - but not yet ratified - United States-Mexico-Canada Agreement require most trade between North American countries to be tariff-free.
Even before the recent negotiations, Lopez Obrador was already quietly complying with U.S. demands to do more to prevent migrants from reaching the U.S.
Between January and May of this year, Mexico detained 74,031 migrants - a 36% increase compared to the same period last year under former Mexican president Enrique Pena Nieto. The number of migrants deported from Mexico tripled from 5,717 in December 2018 to 15,654 in April 2019, government statistics show.
Sending troops out to target migrants, as Mexico has now promised to do, will almost certainly result in the excessive use of force against these migrants.
The Mexican National Guard is an untested new military police force with immigration enforcement powers. Its creation in early 2019 was highly controversial in Mexico given the Mexican military's extraordinarily violent law enforcement record.
Between 2007 and 2017, when troops were helping police fight Mexican drug cartels, the National Human Rights Commission received over 13,700 complaints of human rights violations committed by soldiers against civilians. These included accusations of arbitrary arrests, torture and extrajudicial killings.
Under such an agreement, refugees are required to apply for asylum in the country where they first land and not the country where they ultimately want to settle. This means that one country can reject a person's asylum application if they have already been granted asylum by another country.
Canada and the U.S. signed such an agreement in 2002, and Trump has been pushing Mexico to do the same since spring 2018. Under this proposal, thousands of migrants in Mexico who have already applied for asylum in the United States and are now waiting for an answer would see their applications invalidated.
Foreign Secretary Ebrard consistently rejected that proposal. He insisted that a safe third country arrangement would violate the Mexican Constitution and Mexico's international human rights agreements.
Migrants may end up staying in Mexico for years while they await their asylum hearing in the United States. During that period, Mexico will be responsible for housing, feeding and protecting refugees.
Jorge Castaneda, Mexico's secretary of foreign affairs from 2000 to 2003, has derided Mexico's commitment as a "light" safe third country agreement.
The mere idea that Mexico is safe is "a particularly cynical bout of wishful thinking," as Mexican journalist Leon Krauze put it in a recent Washington Post op-ed.
Mexico is one of the world's most dangerous places. An estimated 33,000 people were murdered there last year - twice the average annual homicides in the United States in a country with less than half the population.
Dozens of Central Americans have disappeared from migrant caravans journeying northward in Mexico. Over 90% of migrants say they do not feel safe in Mexico, according to a survey of 500 Central American asylum-seekers conducted in February 2018.
Mexico must do more with less
The "Remain in Mexico" policy is likely to result in a significant increase in claims filed for asylum in Mexico, where the immigration system is already under enormous strain.
Around 29,000 people applied for asylum in Mexico in 2018, according to United Nations data. This year, between January and March, Mexico received 12,716 asylum applications - 43% of last year's total in just three months.
The Mexican Commission for Refugee Assistance, which processes asylum claims, currently has a two-year backlog.
It will now have to do more with less.
More migrants, less money, extreme violence and a recalcitrant, unpredictable northern neighbor - these are the ingredients of a refugee crisis, not a diplomatic victory.
Author: Luis Gmez Romero - Senior Lecturer in Human Rights, Constitutional Law and Legal Theory, University of Wollongong