NEW YORK — Stocks rallied to finish higher Wednesday, overcoming worries about an escalating trade dispute between the U.S. and China.

After plunging 501 points at the open, the Dow Jones industrial average finished with a gain of 230 points, or about 1 percent.

Technology stocks reversed early losses, with the notable exception of Facebook, which fell slightly. Consumer stocks were strong, but industrials such as plane maker Boeing and farm equipment maker Deere, which could be hurt by any tariffs, closed with losses.

The whiplash followed announcements by the U.S. and Chinese governments that they plans to impose tariffs of 25 percent on $50 billion worth of the others’ imports. Some analysts downplayed the back-and-forth as negotiating tactics.

The S&P 500 finished up 30 points, or 1.2 percent, at 2,644.69.