President Trump said Friday that he would double the rate of tariffs on steel and aluminum imports from Turkey, inflicting additional pain on President Recep Tayyip Erdogan, whose country is in the midst of an economic crisis.

Trump’s abrupt and unilateral action came amid worsening relations with Turkey, which has continued to detain an American pastor on espionage charges despite the United States’ insistence that he be released.

In a Twitter post Friday morning, Trump said the United States would bump Turkey’s aluminum tariffs to 20 percent and steel tariffs to 50 percent and cited the country’s deteriorating currency, the Turkish lira. “Our relations with Turkey are not good at this time!” he said.

While Trump’s decision is primarily aimed at punishing Turkey over its failure to return the American pastor, Andrew Brunson, the decision spooked markets and raised the possibility he could similarly raise tariffs on other trading partners that have seen their currencies fall, most notably China. Trump already has threatened to increase tariff rates on $200 billion worth of Chinese goods to 25 percent from 10 percent, in part because of the sharp decline in its currency.

Trump’s mention of the currency suggested he is concerned that a rapid depreciation in Turkey’s currency has essentially mitigated the effect of his tariffs. Since a weaker currency makes it less expensive for countries to export their goods, the tariffs carry less punch. By doubling the rate, Trump’s levies will continue to hurt Turkish metal exporters.

Ruhsar Pekcan, the Turkish minister of trade, said Turkey was “deeply disappointed” by the decision to double the tariffs. “The tariffs were groundless when they were announced in June, and remain so now,” Pekcan said.

“The effects of this ill-advised action by the U.S. administration will not only impact Turkey, but will prove detrimental to American companies and workers as well,” he added.

In his tendency to mix trade goals with other political concerns, Trump has deviated from decades of government practice. He suggested earlier this year that he might soften his trade approach to China in return for Beijing’s help in dealing with the North Korean regime, and repeatedly tied Mexican trade practices with immigration issues.

Jim Tankersley, Ana Swanson and Matt Phillips are New York Times writers.