Donald Trump has announced that he is placing a 5% tariff on all Mexican imports to pressure the country to do more to curb immigration into the US, in a surprise move that has rattled markets.

The US president said the tariff would gradually increase “until the illegal immigration problem is remedied”. He made the announcement via Twitter after telling reporters earlier on Thursday he was planning “a major statement” that would be his “biggest” so far about the border.

With investors afraid that increasing trade friction could hurt the global economy, the Mexican peso, US stock index futures and Asian stock markets tumbled, including the shares of Japanese carmakers who export from Mexico to the US.

It raised the risk of devastating economic relations with the biggest US trade partner for goods. Mexico, which relies heavily on cross-border trade, rose to that ranking as a result of Trump’s trade war with China. Rufus Yerxa, the president of the National Foreign Trade Council, which represents the largest US exporters, told the New York Times the move was “a colossal blunder”.

Q&A What is a tariff? Show Tariffs are border taxes charged on foreign imports. Importers pay them upon entry to the customs agency of the country or bloc imposing them. Tariffs can be levied in different ways. It can be a flat-rate tariff linked to weight, or calculated as a proportion of the overall value of the goods. It can also be a mixture of both. A country can set a quota, enabling a certain volume of a product to flow in before a higher tariff rate kicks in. Tariffs raise money for governments, but are primarily used to raise the price of foreign goods, protecting domestic producers from global competition.

Countries signed up to the World Trade Organization (WTO) must impose tariffs at the same level for all other WTO-member trading partners under the organisation’s “most favoured nation” rule – unless they secure alternative deals with particular countries or trading blocs. Richard Partington

Mexico’s leftwing president, Andrés Manuel López Obrador, commonly called “Amlo”, responded to Trump with a two-page letter in which he wrote: “The Statue of Liberty is not an empty symbol … With all due respect, even though you have the right to say it, ‘make America great again’ is a fallacy because, until the end of times, and beyond national borders, universal justice and fraternity should prevail.”

López Obrador offered his US counterpart history lessons on past periods of cordial US-Mexico relations. He also included details of his plans to develop Central America to stop migration and warned: “I don’t lack courage, I’m not a coward nor timid, rather, I act on principles.”

Trump has accused the Mexican government of failing to do enough to crack down on the number of migrants entering the US in search of asylum from Central American countries including El Salvador, Honduras and Guatemala.

López Obrador, however, was blunt about the crisis: “President Trump, social problems aren’t resolved with taxes or coercive measures,” he said, defending his administration’s handling of the migration issue.

Thousands of people remain stranded in the southern Mexican state of Chiapas, unable to obtain immigration documents, while asylum seekers must wait in northern Mexican border cities as their cases are heard in US courts.

Trumps said the US would impose the 5% tariff from 10 June, and it would rise steadily to 25% until illegal immigration across the southern border was stopped. If implemented, the measures are bound to trigger retaliation that would hit Trump-supporting farming and industrial states.

In Beijing, the foreign ministry spokesman, Geng Shuang, expressed sympathy for Mexico. “The United States has repeatedly taken trade bullying action. China is not the only victim,” Geng told reporters.

The White House said Trump would use the International Emergency Economic Powers Act to implement the tariffs. “If the illegal migration crisis is alleviated through effective actions taken by Mexico, to be determined in our sole discretion and judgment, the tariffs will be removed,” the White House said.

Trump’s announcement comes as the administration pushes for the passage of the US-Mexico-Canada Agreement, which would update the North American Free Trade Agreement.

The White House chief of staff, Mick Mulvaney, insisted on Thursday that imposing tariffs on Mexican imports would not interfere with the continuing negotiations over a trade deal. “The two are absolutely not linked,” he told reporters.

Asked about the impact of the tariffs on the economy, Mulvaney said illegal immigration was “already impacting the economy negatively”.

In the biggest migration surge on the US-Mexican border in a decade, US officials say 80,000 people are being held in custody and an average of 4,500 mostly Central American migrants arriving daily, overwhelming the ability of border patrol officials to handle the numbers.

Mulvaney said the White House briefed Republican members of Congress before the plan was announced and that lawmakers were generally supportive. But Trump’s aggressive trade policies have divided Republicans and sparked fears for the US and global economy.

During a visit to Canada on Thursday, the vice-president, Mike Pence, vowed the trade deal would be passed this year.

Asked by reporters about the new tariff, Pence said both Mexico and Congress needed to do more and that Trump was determined to use his authority to call on them to do so.

Reuters contributed to this report