Stocks opened trading lower after the announcement, but found their footing and began to move higher. Then, around 11 a.m., Mr. Trump took to Twitter.

“We don’t need China and, frankly, would be far better off without them,” he wrote in one message.

In another post, Mr. Trump said that American companies were “hereby ordered to immediately start looking for an alternative to China,” adding that he would respond to China’s tariff threat later in the day.

Around 5 p.m., Mr. Trump said would increase the existing tariffs on $250 billion of Chinese goods to 30 percent from the current 25 percent, beginning Oct. 1. He also said the United States would tax another $300 billion in Chinese imports at a rate of 15 percent rate, rather than the 10 percent he had initially planned to go into effect in September.

Almost immediately after the president’s late-morning tweets, shares began to dive as investors turned their attention away from the calming effects of a speech by Jerome H. Powell, the Federal Reserve chair, and back toward the trade war between the world’s two largest economies.

The trading on Friday was a prime example of the crosscurrents that are confounding investors. Throughout the year, stocks have tumbled on concerns about the continuing trade fight, only to be lifted by hopes that interest-rate cuts by the Fed would contain the damage caused by the conflict. More tariff threats from Beijing or Washington then start the cycle again.