NEW YORK, July 12 (Reuters) - Stock markets around the world bounced back on Thursday, with U.S. gains led by merger activity and earnings optimism that offset concerns over an escalating U.S. trade battle with China that had weighed on markets a day earlier.

Metals also rebounded, with bargain-hunting investors scrambling to buy, while oil prices struggled to hold on after clawing back big losses.

Stocks on Wall Street got a boost from technology and industrial shares. CA Inc jumped 18.1 percent after chipmaker Broadcom announced a surprise $18.9 billion deal to buy the U.S. business software company.

There was also some relief for markets as President Donald Trump came out of a meeting of the NATO military alliance in Belgium with a positive assessment, after a string of earlier barbs.

"We had a fantastic meeting at the end," Trump told reporters. "Very unified, very strong, no problem."

The Dow Jones Industrial Average rose 165.53 points, or 0.67 percent, to 24,865.98, the S&P 500 gained 14.62 points, or 0.53 percent, to 2,788.64 and the Nasdaq Composite added 64.84 points, or 0.84 percent, to 7,781.45.

Stocks in Shanghai jumped more than 2 percent as trade war tensions faded to the background for now.

"While markets have typically reacted negatively to any escalation on trade, the overall impact has been relatively modest under the circumstances which suggests investors are far from panic mode right now," Craig Erlam, Oanda senior market analyst, said in a note.

"There still seems to be some hope that common sense will prevail and a full blown trade war will be averted."

Positive U.S. jobless data on Wednesday provided a market boost, with labor market conditions remaining robust in early July.

In addition, a consumer prices report indicated the underlying trend continued to point to a steady buildup of inflation pressure that could keep the Federal Reserve on a path of gradual interest rate hikes.

The inflation data also boosted the U.S. dollar, which rose to a six-month high against the Japanese yen.

In part, currency investors may see positive implications for the dollar from a trade war, as the United States would be better equipped to weather a slowdown in trade than other major economies.

The Japanese yen weakened 0.38 percent versus the greenback at 112.45 per dollar.

Oil prices, which had rebounded, turned negative after the International Energy Agency (IEA) said the world's oil supply cushion "might be stretched to the limit" due to production losses.

Metals prices rebounded after a meltdown following Trump's threats for 10 percent tariffs on another $200 billion of Chinese goods.

Nickel touched its highest in a week as investors scrambled to buy at the cheaper prices.