Donald Trump announced on Monday that he will restore tariffs, effective immediately, on all steel and aluminum shipped into the United States from Brazil and Argentina.

In a surprise move, Trump accused the two countries of devaluing their currencies and hurting US farmers. All the US stock markets fell on fears of rising trade tensions.

“Brazil and Argentina have been presiding over a massive devaluation of their currencies. which is not good for our farmers,” Trump said in a tweet.

The announcement came as a symbolic slap in the face for Brazil’s President Jair Bolsonaro, who has positioned himself as Trump’s closest ally in the Americas. Bolsonaro told Brazil’s Rádio Itatiaia: “I’m going to call him so that he doesn’t penalize us … Our economy basically comes from commodities, it’s what we’ve got. I hope that he understands and that he doesn’t penalize us with this, and I’m almost certain he’ll listen to us.”

Brazil’s main steel industry body, Instituto Aço Brasil, said that it was “perplexed” by the decision and argued that the move would hurt US businesses who use Brazilian steel.

Argentina’s production minister, Dante Sica, called Trump’s announcement “unexpected” and said he was seeking talks with US officials.

The US’s long-running trade war with China has benefited Argentina and Brazil as China has bought more agricultural goods from the Latin American countries in retaliation. But both countries are struggling economically. Brazil’s currency, the real, hit a record low last week and unemployment is above 10%. In Argentina inflation is above 50% and a third of the population live in poverty.

The news came after a week in which it appeared that the White House was tempering its long-running trade disputes in the lead-up to next year’s election. Trump administration officials had hoped to sign a “phase one” deal with Beijing, removing some tariffs, before 15 December, when the US is set to impose an additional 15% tariff on about $156bn of Chinese products.

The commerce secretary, Wilbur Ross, told Fox Business on Monday that the new tariffs were still on the table. “If nothing happens between now and then, the president has made quite clear he’ll put the tariffs in,” he said.

In recent weeks the administration has also appeared closer to a deal with Democrats to revamp the North American Free Trade Agreement, now known as the United States-Mexico-Canada Agreement. But the potential agreements are at the mercy of Trump’s mercurial negotiating style.