Tijuana (Mexico) (AFP) - Presidents Donald Trump and Andres Manuel Lopez Obrador each declared the deal averting US tariffs on Mexico a win Saturday, as markets breathed a sigh of relief -- though rights groups condemned what they called a draconian crack down on migration.

Lopez Obrador said the bottom line on the last-minute deal reached Friday night was simple: "there will not be an economic or financial crisis in Mexico on Monday."

Economists had warned the pain of Trump's threatened tariffs -- set to start at five percent Monday and rise incrementally to 25 percent by October -- and Mexico's likely retaliatory measures would have been acute for both countries, with potentially global spillover.

Instead, the countries hammered out a deal in which Mexico agreed to bolster security on its southern border and expand its policy of taking back migrants, most of them from violence-riven Guatemala, Honduras and El Salvador, as the United States processes their asylum claims.

Trump hailed it as a victory, after a week of terrifying his southern neighbor, whose economy depends heavily on exports to the US.

"Mexico will try very hard, and if they do that, this will be a very successful agreement for both the United States and Mexico!" he tweeted early Saturday.

Later, he added: "Everyone very excited about the new deal with Mexico!"

The relief was palpable in the Mexican border city of Tijuana, where Lopez Obrador led a rally attended by several thousand people to celebrate the deal and "the friendship of the people of Mexico and the United States."

However, the leftist leader -- who said he had just spoken to Trump on the phone -- also warned his American counterpart that it was not enough for Mexico to tighten its borders, saying Washington also needed to invest in economic development in Central America to stem the exodus from the region.

"The solution cannot be found in just closing borders or coercive measures. The only solution is to fight the lack of opportunity and poverty so that migration is optional," he said, speaking on a stage set up, with seeming symbolism, next to a McDonald's five blocks from the border.

Story continues

- Border crack down -

For many, the episode was vintage Trump behavior: trigger a crisis and let it simmer for a while, then declare it resolved and take credit.

The New York Times reported Saturday that most of the measures that Mexico signed on to in Friday's deal had already been agreed upon in prior negotiations.

Some advocacy groups in Mexico criticized the deal, saying the plan to deploy the newly created National Guard to the southern border would militarize a humanitarian problem and result in mass detentions of innocent women and children.

The deal criminalizes migration, said activist Luis Rey Villagran of the Center for Human Dignity.

"In this agreement, the migrants are currency," he said. "The National Guard should be combatting drug traffickers, not focusing on stopping children and women who are trying to fulfill their dreams."

Some opponents accused Lopez Obrador of playing into Trump's hands.

"It will make Donald Trump so happy to say he didn't have to build his border wall because Mexico is now the wall," tweeted Mexican writer Esteban Illades.

But Mexico managed to dodge one of Trump's main demands: to accept a "safe third country" agreement in which refugees arriving in Mexico would be forced to seek asylum there rather than the US.

There was also acute awareness the tariffs would have clobbered the Mexican economy, which exports $350 billion in goods each year to the US.

Economists warned the tariffs would also hurt US companies that have set up complex supply chains across the borders with Mexico and Canada under the North American Free Trade Agreement, and lead to higher prices on everything from tequila to refrigerators for US consumers.

The tariffs also drew unusually strong opposition from Trump's fellow Republicans, especially lawmakers from farm states who worried about losing their second-largest international market.

- 'Unprecedented steps' -

Mexico pledged to take "unprecedented steps" to curb the record flow of migrant families arriving at the US border.

The number of migrants detained or blocked at the border surged to 144,000 in May -- triple the level a year earlier -- including an unprecedented 89,000 in families.

The United States, making official a policy that has triggered opposition in both countries, said it would systematically send back asylum seekers who cross the border, pending a decision on their claims. Lopez Obrador said Mexico would offer them jobs, health care and education.

Thousands have already been sent back, prompting criticism from human rights campaigners that the migrants will lack due process and face danger in Mexican border cities such as Ciudad Juarez.

Trump, who has declared a crisis at the border and earlier deployed troops, says that asylum seekers can too easily slip into the population while on US soil.

Democrats denounced the president for taking the United States and Mexico to the brink.

"Threats and temper tantrums are no way to negotiate foreign policy," top Democratic lawmaker Nancy Pelosi said in a statement.