The Mexican government will deploy 6,000 troops to its southern border with Guatemala on Monday — members of a billion-dollar force originally set up to combat drug-trafficking cartels — as part of a series of “unprecedented steps” meant to stem the massive influx of migrants to the US, the State Department said.

The agreement, reached late Friday after three days of intense negotiations in Washington, is a victory for President Trump after he threatened to impose tariffs on Mexican goods if the country does not crack down on Central American migrants journeying through Mexico toward the US’s southern border.

Mexico’s newly created National Guard will take the lead in the enforcement effort, according to reports in Mexican media. A group of 200 troops were already on Mexico’s southern border this past week to intercept a caravan of 500 migrants that arrived Wednesday. The 60,000-strong force was established in March.

“Mexico will try very hard, and if they do that, this will be a very successful agreement for both the United States and Mexico!” Trump boasted in a Saturday tweet.

Mexico also agreed to accept more migrants from the US. It promised to provide them with education, work permits and health services.

The deal is meant to foil American judicial rulings that have forced the Trump administration to allow migrants claiming asylum status to remain in the US while their cases are decided — the so-called “catch-and-release” policy that has encouraged hundreds of thousands to illegally cross the border.

Despite the program’s steep price tag, which could amount to millions of dollars, Mexican Foreign Minister Marcelo Ebrard said he was “satisfied” with the results of negotiations. The talks took place at the State Department, beginning around 7 am and not ending until late in the evenings.

“I would like to thank the President of Mexico, Andres Manuel Lopez Obrador, and his foreign minister, Marcelo Ebrard, together with all of the many representatives of both the United States and Mexico, for working so long and hard to get our agreement on immigration completed!” Trump tweeted Saturday.

According to the declaration, both countries will continue to brainstorm other measures to be announced in the next three months.

This past week, Mexican authorities broke up the caravan after it crossed the Guatemalan border and traveled through Chiapas state. The migrants were taken to nearby Tapachula, where they have been detained by Mexican immigration police.

Mexico did not accede to Trump’s demand that it accept “safe third country” status, which would require Central American migrants to seek asylum there rather than in the United States.

And the US kept a potential tariff threat on the table, saying that “further actions” could be taken if Mexico falls short on its promise to curb migrant flows.

Trump foes including Rep. Alexandria Ocasio-Cortez (D-NY) begrudgingly praised the deal.

“Any movement towards not having a tariff is a positive development, so that’s a good thing,” AOC told The Post on Saturday. “But I think it’s just very disturbing that these tariffs are being announced and revoked on such a volatile basis.”

Additional reporting by Olivia Bensimon