NEW YORK - World stocks edged lower Tuesday despite broad gains in Europe and rising oil prices as markets remained in the grip of trade turbulence.

A July 6 deadline is looming for Washington to impose tariffs on $34 billion worth of Chinese goods that Beijing has vowed to match with tariffs on U.S. products. President Donald Trump also threatened on Monday to “do something” if the United States was not better treated by the World Trade Organization.

Prospects of a full-blown trade war and relentless yuan weakening - it has fallen 5 percent in the past two weeks and is near 11-month lows - reportedly forced China into intervention via state-run banks.

“It is by far the biggest (yuan loss) I can remember. Prudence suggests it has to be matched across Southeast Asia because of the competitive implications,” said Bank of New York Mellon strategist Neil Mellor. “It generates a degree of instability in the market simply by virtue of its scale.”

Among equity markets, Hong Kong dived as much as 3.3 percent to nine-month lows, hit also by U.S. curbs on China Mobile. Shanghai’s bourse hit a two-year trough but closed higher as the yuan recovered.

The mood was more cheerful in Europe where a pan-European equity index rose 1 percent, the euro firmed and bond yields climbed after German Chancellor Angela Merkel struck a migration deal with her Bavarian conservative coalition partners.

MSCI’s gauge of stocks across the globe shed 0.01 percent.

FILE PHOTO: Traders work on the floor of the New York Stock Exchange (NYSE) in New York, U.S., July 2, 2018. REUTERS/Brendan McDermid

In the United States, benchmark indices closed in the red after trading for much of the day in positive territory during a holiday-shortened session. The Dow Jones Industrial Average fell 132.36 points, or 0.54 percent, to 24,174.82, the S&P 500 lost 13.49 points, or 0.49 percent, to 2,713.22 and the Nasdaq Composite dropped 65.01 points, or 0.86 percent, to 7,502.67.

Shares of Facebook Inc fell 2.3 percent after the Washington Post reported a federal probe on a data breach linked to Cambridge Analytica had been broadened and would include more government agencies. That hit other technology shares as well.

“The big driver behind U.S. resilience is that tech has been strong,” said Rory McPherson, head of investment strategy at asset manager Psigma. “Expectations are pretty high for the earnings season, with talk of 20 percent earnings growth year-on-year.”

Energy stocks have been boosted by Brent crude’s rise past $78 a barrel, McPherson noted. Europe’s tech and energy sectors rose 0.5 and 1 percent respectively.

While U.S. growth and company earnings seem unassailable, tit-for-tat tariffs from China and Europe may ultimately prove detrimental for American businesses and jobs.

U.S. bond yields rose slightly amid the easier mood but concern about the trade row has helped push the gap between two- and 10-year yields to the narrowest since 2007.

“Basically (the flat curve) is saying the underlying growth in the U.S. economy may not be as strong as the high short-term interest rates might warrant,” McPherson said.

The dollar retreated 0.4 percent against a basket of currencies and the easing tensions in Germany helped the euro to gain 0.2 percent against the greenback.

Friday’s monthly payrolls data should show labor markets remain tight, keeping the U.S. Federal Reserve’s policy tightening on track.

“Notwithstanding the trade war concerns, the broader picture is the U.S. central bank still remains the most hawkish central bank among its peers and that should support the dollar for now,” said Jane Foley, senior currency strategist at Rabobank.