MEXICO CITY — As fears grew about Mexico’s deteriorating relationship with its No. 1 trade partner, the Mexican government went into diplomatic overdrive Friday to head off punishing tariffs threatened by the Trump administration in retaliation for the rising number of migrants reaching the U.S. border.

Foreign Minister Marcelo Ebrard spoke by phone with U.S. Secretary of State Mike Pompeo and Jared Kushner, President Trump’s adviser and son-in-law. “The process of negotiation has begun,” the Mexican minister tweeted.

Shortly thereafter, he announced a high-level meeting in Washington on Wednesday aimed at resolving the trade dispute. “There is willingness to have a dialogue,” he tweeted. “We will be firm and defend the dignity of Mexico.”  

Ebrard’s diplomatic initiative reflected this country’s grave concern about Trump’s threat to impose a series of 5 percent tariffs on goods from Mexico unless it stops the growing stream of Central American migrants transiting the country.  

Mexico and the United States are each other’s top trading partner. Mexico is particularly dependent on cross-border commerce, sending 80 percent of its exports to its northern neighbor. It has been anxiously seeking to fortify its trade relationship through ratification of the U.S.-Mexico-Canada Agreement — the updated version of the North American Free Trade Agreement.  

“The imposition of these tariffs would destroy NAFTA and the USMCA,” which is intended to succeed it, said Luis de la Calle, a former top Mexican trade negotiator. “What sense would it have to have a treaty if the U.S. doesn’t respect it?”

President Andrés Manuel López Obrador, a leftist who took office in December, has sought to maintain a cordial relationship with Trump. He struck a conciliatory tone Friday, saying, “There is no need for confrontation.”

But the Mexican peso suffered one of its worst days of the year Friday, dropping as much as 3 percent, while the Mexican stock market slid by over 1 percent. Investors were clearly worried. 

Mexicans on Friday rallied around López Obrador, who is commonly known here by his initials, AMLO. Tens of thousands of people used #AMLOEstamosContigo — “AMLO, we are with you” — in Twitter messages of support. 

López Obrador predicted Trump would change his mind about the tariffs.  

“I think that there will be a correction,” he said. “Perhaps not immediately, but it will happen, because these measures aren’t good for either the Mexicans nor the Americans.”

Exactly what Mexico might be willing to offer the United States in a negotiation was unclear. Kevin McAleenan, the acting head of the Department of Homeland Security, told reporters Thursday that the U.S. government had three key demands: tighter security on Mexico’s porous border with Guatemala; a crackdown on smugglers who transport migrants through Mexico, often on buses; and an arrangement whereby asylum seekers — who make up a vast number of the migrants — could be required to seek refuge in Mexico instead of the United States. 

Some Mexican officials have called for increasing the government’s control of its southern border. But the country’s soldiers and police have been grappling with rising organized-crime violence in other parts of the country. 

López Obrador took office promising a change in Mexico’s treatment of Central American migrants, who have often been abused and extorted by corrupt Mexican police. His government subsequently issued thousands of “humanitarian visas” allowing migrants to work and travel in Mexico.

But as Trump’s criticism of the growing migrant flow has intensified, Mexico has toughened its policies. It deported about 15,600 foreigners in May, up from 5,585 in January, according to government figures obtained by Andrew Selee, head of the Migration Policy Institute, a Washington think tank. 

Mexico also canceled the humanitarian-visa program amid overwhelming demand. And it has agreed to a Trump administration request to host migrants seeking U.S. asylum while they go through the process — which can take months.

Mexico was long a major source of migrants to the United States. But these days, more Mexicans are returning home than moving here, while the numbers of Central Americans apprehended on the U.S. border are surging.  

“The Mexican immigration system was not built to deal with these kinds of flows,” Selee said. Complicating matters, he said, the López Obrador government has fired hundreds of employees of the national migration agency because of corruption.

“It’s the right thing to do,” Selee said, but it means the government has fewer officers to detect and detain migrants in the country illegally. 

While Mexico is eager for a deal to avoid the tariffs, officials have made clear the country is also willing to fight back. Officials say they could use provisions of ­NAFTA, which remains in effect.

“We know that Mexico has the legal and juridical instruments that can be used if necessary,” said Luz Maria de la Mora, the undersecretary of commerce. She added that Trump’s proposed tariffs were “arbitrary and abusive.”  

López Obrador said Friday that Mexico would enforce its immigration laws but would not take actions that violate human rights. He noted that people were leaving Central America “not by choice, but necessity,” because of violence and a lack of jobs.

López Obrador has sought to enlist the United States and other countries in supporting a “Marshall Plan” for Central America aimed at improving infrastructure and job opportunities in a way that would discourage migration. But while Washington has offered loan guarantees, it has not committed substantial funding to the plan. 

Sebastian Fleming-Dresser contributed to this report.