In recent weeks, the pressure on Mr. Trump to reach an accord with Canada and Mexico began to outweigh his affection for the tariffs.

According to a congressional aide who has been involved in the talks among the three countries, the White House was growing increasingly sensitive to pressure from Republicans in rural states, whose farmers have been suffering from retaliation that diminished their access to sell in neighboring markets. Their problems were compounded when talks with China broke down this month, this person said, and ultimately Mr. Trump decided that he needed a victory on trade.

The decision to ease the 25 percent tariffs on steel and 10 percent tariffs on aluminum came as the White House also announced a six-month delay in determining whether to impose levies on foreign automobiles. That extension delivers a temporary reprieve to global automakers and auto suppliers, which had been bracing for punishing tariffs of up to 25 percent. But it sets up a tight deadline for the president and his advisers to reach trade deals with Japan, Europe and potentially other countries.

Farmers, ranchers and business groups had been pushing to lift the metal tariffs, to encourage Canada and Mexico to remove the tariffs they have placed on American products in return. Canadian and Mexican levies on products like pork, cheese and milk have especially hurt American farmers who are already smarting from Mr. Trump’s trade conflicts with China and Europe.

The agreement is likely to help the administration focus on the other trade fights it is waging, most notably fractious negotiations with China, which nearly collapsed last week. And it will remove one obstacle to the passage of the new United States-Mexico-Canada Agreement in Congress.

The United States, Canada and Mexico signed that trade deal, the successor to the North American Free Trade Agreement, in November. The pact still needs to be ratified by legislatures in all three countries.

American lawmakers of both parties, as well as Canada and Mexico, had insisted that tariffs on steel and aluminum must be lifted before votes would be held. Lawmakers have argued that the tariffs, while aimed at other countries, hurt American companies and consumers by raising prices for products that use imported steel and aluminum.