President Trump had threatened tariffs unless Mexico stemmed the flow of migrants heading to the US.