Unforeseen circumstances could change all that. An economic slump could drive one or both of them back to the bargaining table. Mr. Trump has torn up trade deals before. Americans could elect a less trade-hawkish leader in November.

But so far, both countries have shown they are willing to take the economic hit. The American economy, job market and stock market have only improved since the trade war began nearly two years ago, though many question how long that can last. On the political front, many Democrats have pushed Mr. Trump to be harder, not softer, on trade with China.

In China, the trade war has been only one factor behind the slowing economy. Beijing seems comfortable with its ability to handle the problem.

In recent weeks, advisers to the Chinese government have emphasized discussion of steps Beijing can take — like helping the job market or finding new trading partners elsewhere — instead of the steps that it can’t. Even as China’s exports to the United States have plunged, its sales elsewhere, particularly to poor countries, have stayed strong. Beijing has looked hard in recent months to open even more markets.

Also, complaining about the deal could make China look weak, an unpalatable position in a country where the Communist Party portrays itself as the savior from a century of humiliation by foreign powers.

Chinese state media and economists on Thursday welcomed the agreement as a respite for what has been two years of almost unrelenting focus on the trade issue by the government and many in the general public. Wednesday’s pact “will provide at least a truce in the trade war,” said He Weiwen, a prominent Chinese trade economist and former Commerce Ministry official.