WASHINGTON/MEXICO CITY (Reuters) - The United States and Mexico struck a deal on Friday to avert a tariff war, with Mexico agreeing to rapidly expand a controversial asylum program and deploy security forces to stem the flow of illegal Central American migrants.

U.S. President Donald Trump had threatened to impose 5% import tariffs on all Mexican goods starting on Monday if Mexico did not commit to do more to tighten its borders.

In a joint declaration after three days of talks in Washington, both countries said Mexico agreed to immediately expand along the entire border a program that sends migrants seeking asylum in the United States to Mexico while they await adjudication of their cases.

Trump said Mexico had agreed to take strong measures to “reduce, or eliminate” illegal immigration from Mexico.

However, the deal fell short of a key U.S. demand that Mexico accept a “safe third country” designation that would have forced it to permanently take in most Central American asylum seekers.

“The Tariffs scheduled to be implemented by the U.S. on Monday, against Mexico, are hereby indefinitely suspended,” Trump said in a tweet on Friday evening.

Frustrated by a recent surge of migrants that has overwhelmed U.S. resources on its southern border, Trump had used the threat of tariffs to pressure Mexico into making concessions.

He has made hard line efforts to reduce illegal immigration a cornerstone of his presidency and it is certain to be a key issue in his re-election bid next year.

But business groups and even some close Republican allies were unhappy with the prospect of tariffs on the top U.S. trade partner, saying they would damage the economy.

Duties on Mexico would also have left the United States fighting trade wars with two of its three largest trading partners, and would further unnerve financial markets already on edge about a global economic slowdown.

Mexican Foreign Minister Marcelo Ebrard said in Washington his team had also resisted U.S. requests to send deported Guatemalans to Mexico. He said he was satisfied with the deal.

“I think it’s a fair balance because they had more drastic measures and proposals at the start and we reached some middle point,” he said, emphasizing the importance to Mexico of having kept safe third country out of the deal.

He also highlighted U.S. support in the agreement for a Mexican proposal to jointly address underlying causes of migration from Central America.

Slideshow ( 6 images )

The asylum program to be expanded is commonly known as Remain in Mexico, and currently operates in the border cities of Tijuana, Mexicali and Ciudad Juarez.

Under the new deal, returned asylum seekers will spend long periods in Mexican cities such as Reynosa on the Texas border, where drug cartels frequently kidnap migrants.

The program was challenged in court earlier this year by the American Civil Liberties Union (ACLU) and other rights groups which say it puts asylum seekers in danger and violates U.S. and international law.

Slideshow ( 6 images )

While a federal judge ruled to halt the policy, a U.S. appeals court overturned the decision, allowing the policy to continue as the legal challenge is ongoing. Through June 5, 10,393 mostly Central Americans have been sent back to Mexico since the program started in January.

Omar Jadwat, director of the ACLU’s Immigrants’ Rights Project, said the group would continue to press its legal challenge to the policy.

Under the deal, Mexico will also increase its efforts to stop illegal migrants from Central America traveling through Mexico to the United States. Those measures will include deploying the militarized National Guard security force to its southern border.

Ebrard said the National Guard deployment would start on Monday.

The two countries will continue discussions, to be completed in 90 days, on further steps, according to the declaration.

U.S. border officers apprehended more than 132,000 people crossing from Mexico in May, the highest monthly level since 2006. Trump, who has called the surge in migrants an “invasion,” had threatened to keep raising duties up to 25% unless Mexico addressed the problem.

Mexico had prepared a list of possible retaliatory tariffs targeting products from agricultural and industrial states regarded as Trump’s electoral base, a tactic China has also used with an eye toward the Republican president’s 2020 re-election bid.

The United States slapped tariffs of up to 25% on $200 billion in Chinese imports last month, prompting Beijing to levy its own tariffs on $60 billion in American goods. Trump said on Thursday he would decide later this month whether to hit Beijing with tariffs on an additional list of $300 billion in Chinese goods.

Economists have said that two trade disputes could damage supply lines and pinch consumers at a time when the global economic expansion that followed the 2008 financial crisis has started to sour and the risk of recession has risen.

Even the United States, one of the more solid performers on the economic stage, would not be immune to the downdraft.

The U.S. Labor Department reported on Friday that job growth slowed sharply in May and wages rose less than expected, raising fears that a loss of momentum in economic activity could be spreading to the labor market.

(For a graphic on border apprehensions and U.S.-Mexico trade click tmsnrt.rs/2Khd82D)