WASHINGTON — The United States and the European Union stepped back from the brink of a trade war on Wednesday, after President Trump said the Europeans agreed to work toward lower tariffs and other trade barriers, and to buy billions of dollars of American soybeans and natural gas.

The surprise announcement, made by Mr. Trump and the president of the European Commission, Jean-Claude Juncker, defused, for the moment, a trade battle that began with Mr. Trump’s tariffs on steel and aluminum exports and threatened to escalate to automobiles.

“We’re starting the negotiation right now, but we know very much where it’s going,” Mr. Trump said, standing next to Mr. Juncker at a hastily scheduled appearance in the White House Rose Garden.

Mr. Juncker said, “I had the intention to make a deal today, and we have made a deal today.”

The two sides, he said, had agreed to hold off on further tariffs, and work toward dropping the existing ones on steel and aluminum, while they tried to work out a deal to eliminate tariffs, nontariff barriers and subsidies on industrial goods, excluding autos.