Media playback is unsupported on your device Media caption A look at the steps Mexico is taking to deal with migrants

President Donald Trump has hailed a deal reached with Mexico to help stem the flow of migrants to the US after he threatened to impose trade tariffs.

Under the deal, in which Mexico agreed to take "unprecedented steps", the duties that were due to come into effect on Monday have been suspended.

"Mexico will try very hard, and if they do that, this will be a very successful agreement," said Mr Trump.

There were fears that the tariffs could hurt US businesses and consumers.

Under Mr Trump's proposal, duties would have risen by 5% every month on goods including cars, beer, tequila, fruit and vegetables until they hit 25% in October.

The deal was reached at the end of three days of negotiations which saw Washington demand a crackdown on Central American migrants.

What do we know about the deal?

In a joint declaration released by the US state department, the two countries said Mexico would take "unprecedented steps" to curb irregular migration and human trafficking.

But it seems the US did not get one of its reported key demands, which would have required Mexico to take in asylum seekers heading for the US and process their claims on its own soil.

Under the deal, Mexico agreed to:

Deploy its National Guard throughout the country from Monday, pledging up to 6,000 additional troops along Mexico's southern border with Guatemala

Take "decisive action" to tackle human smuggling networks

The US agreed to:

Expand its programme of sending asylum seekers back to Mexico while they await reviews of their claims. In return, the US will "work to accelerate" the adjudication process

Both countries pledged to "strengthen bilateral co-operation" over border security, including "co-ordinated actions" and information sharing.

Media playback is unsupported on your device Media caption Five numbers that explain why the current US border situation is different

The declaration added that discussions would continue, and final terms would be accepted and announced within 90 days.

Should Mexico's actions "not have the expected results", the agreement warned that additional measures could be taken but did not specify what these would be.

In one of a series of tweets about the deal, Mr Trump quoted National Border Patrol Council president Brandon Judd as saying: "That's going to be a huge deal because Mexico will be using their strong Immigration Laws - A game changer. People no longer will be released into the U.S."

Mexican Foreign Secretary Marcelo Ebrard told journalists: "I think it was a fair balance, because they have more drastic measures and proposals at the start, and we have reached some middle point."

Speaking at a separate news conference, US Treasury Secretary Steven Mnuchin said "we couldn't be more pleased with the agreement".

Mr Trump caught members of his own party unaware when he announced the proposed tariffs last week.

Trump tariff threat recedes - for now

By Will Grant, BBC Mexico and Central America correspondent

It's still unclear whether it was internal pressure within his party or the measures being offered by Mexico that dissuaded Mr Trump from implementing the plan, or perhaps simply an appreciation of its potential consequences.

It became apparent during the talks just how intertwined the two neighbouring economies are, and many argued that a 5% tax on all Mexican goods would hurt US suppliers and customers too. Furthermore, damaging the already fragile Mexican economy could have pushed it into a full recession and created more migrants heading north in search of work.

Still, some considered the bilateral meetings were useful, in part to recognise that both nations are facing a steep rise in undocumented immigration.

The plan to deploy military personnel to Mexico's southern border may well have helped bring this dispute to an end. However, President Trump has now tied immigration to bilateral trade and could easily do so again in the future should the situation fail to improve.

What is the reaction in Mexico?

Mexico is currently one of the largest trading partners of the US, just behind China and Canada - two countries also locked in trade disputes with the US.

President Andrés Manuel López Obrador ran for office vowing to stand up to the US and once said he would not allow Mexico to be Mr Trump's "whipping boy".

But some Mexican politicians felt he had given too much, too quickly, and they demanded to see details of the deal.

Ángel Ávila Romero, a senior member of the left-wing PRD party, said the agreement was "not a negotiation, it was a surrender".

"Mexico should not militarise its southern border. We are not the backyard of Donald Trump," he tweeted.

Media playback is unsupported on your device Media caption Why are Africans in Mexico heading to US?

Marko Cortés, leader of the conservative National Action Party (PAN), said the sovereignty and dignity of Mexico had been damaged, newspaper El Universal reported.

Mr López Obrador said on Twitter that a rally in the border city of Tijuana on Saturday to celebrate Mexican sovereignty would go ahead.

What's the situation on the US-Mexico border?

On Wednesday, US Customs and Border Protection said migrant detentions had surged in May to the highest level in more than a decade - 132,887 arrests, a 33% increase from April.

The detentions were the highest monthly total since Mr Trump took office.

Official figures show illegal border crossings had been in decline since 2000. In 2000, 1.6 million people were apprehended trying to cross the border illegally - that number was just under 400,000 in 2018.

In 2017, Mr Trump's first year in office, the figures were the lowest they had been since 1971. But the number of arrests has been rising again, especially in recent months.

In February, Mr Trump declared an emergency on the US-Mexico border, saying it was necessary in order to tackle what he claimed was a crisis.