President Trump announced Monday that his administration has inked a secret agreement with Mexico on immigration enforcement that will be unveiled in the “not too distant future.”

But the revelation stumped Mexican Foreign Secretary Marcelo Ebrard, who said he wasn’t aware of any such deal.

“We have fully signed and documented another very important part of the Immigration and Security deal with Mexico, one that the U.S. has been asking about getting for many years,” Trump wrote on Twitter.

“It will be revealed in the not too distant future and will need a vote by Mexico’s Legislative body!”

But Trump warned that if there is a problem and the “approval is not forthcoming,” tariffs against Mexican imports will be ­imposed.

The Trump administration has been prodding Mexico to enter into a “safe third country” agreement, which would deem Mexico a safe place for migrants and make it more difficult for migrants from Central America to pass through the country and claim asylum at the US border.

But the deal announced last Friday made no mention of that issue.

Mexico insisted it has not agreed to the safe third country provision, and confirmed, as Trump said, that it would require approval from local lawmakers.

“They wanted something else totally different … to be signed,” Ebrard said of the Trump administration at a news conference in Mexico City. “But that is what there is here. There is no other thing beyond what I have just explained.”

Mexico has resisted such a designation, though a US official claimed Mexico has expressed an openness to the idea behind closed doors and discussions will continue in the coming months.

Ebrard said if the deal announced Friday does not begin to drive down migrant numbers in the next 45 days, officials will open up new discussions.

“We told them — I think it was the most important achievement of the negotiations — ‘Let’s set a time period to see if what Mexico is proposing will work, and if not, we’ll sit down and see what additional measures’ ” are needed, Ebrard said.

The aim would be to establish a regional refugee system in conjunction with the United Nations and the governments of Guatemala, Panama and Brazil — three countries that migrants flee and head to the US.

On Friday, Trump backed off slapping Mexico with a series of 5 percent tariffs after Mexico offered a number of concessions — including sending national guard troops to the Guatemala border.

But the New York Times reported that many of the proposals had been in discussion for months, leading Trump to call the newspaper “failing.”

In an interview on CNBC, Trump defended his use of tariffs as a negotiating tool that forced Mexico to reach the deal with the US.

He also predicted that such levies would pressure China to give in on trade talks with the US.

“People haven’t used tariffs, but tariffs are a beautiful thing when you are the piggy bank. When you have all the money, everyone is trying to get our money,” the president said on CNBC’s “Squawk Box.”

Over the weekend, Trump also claimed that Mexico agreed to buy more agricultural products from the US. But Mexican officials said no agreement was reached on farm products and the talks focused on migrant issues, not commerce.

With wires