U.S. stocks kicked off the third quarter on a positive note Monday, with the main indexes reversing early losses to finish higher on the back of a rally in technology shares. However, worries over trade tensions between the U.S. and its major trading partners lingered, weighing on investors’ sentiment.

The Dow Jones Industrial Average DJIA, +0.17% rose 35.77 points, or 0.2%, to 24,307.18. The S&P 500 SPX, +0.26% gained 8.34 points, or 0.3%, to 2,726.71 and the Nasdaq Composite Index COMP, +0.37% climbed 57.38 points, or 0.8%, to 7,567.69.

Read:Which markets are closed for July Fourth?

What drove the markets?

Recent trading has been colored by uncertainty over trade policy, with investors seeking clarity about potential protectionist changes to U.S. policies and how they could be met by retaliatory measures. A trade war is seen as providing a significant headwind to global growth.

On Sunday, President Trump said he sees his threat to impose global auto tariffs as his biggest weapon to extract concessions from trading partners. At the same time, he called the EU “as bad as China” in hindering U.S. trade.

Meanwhile, a Financial Times report on Sunday said the European Union has threatened $300 billion in fresh tariffs against U.S. products if Trump follows through on his threatened 20% levies targeting the trade bloc’s auto makers. And Canadian retaliatory tariffs took effect Sunday, with those measures serving as a response to U.S. metals tariffs.

In another significant question mark, Axios reported that the Trump administration had crafted a draft bill that would declare America’s abandonment of World Trade Organization rules. This would essentially give Trump a license to raise tariffs at will, without congressional consent and largely outside of the international rules governed by the WTO.

Trading may be volatile this week, as some market participants will be out of the office for the Fourth of July holiday, for which markets will be closed on Wednesday. Lower trading volume can exacerbate day-to-day swings.

Don’t miss:Trade-war fears? These lower-risk stocks are weathering the market storms

And see:Here’s the key question for U.S. investors about the trade skirmish with China

Which economic reports are in focus?

A read on June manufacturing from Markit came in at 55.4, compared with a preliminary reading of 54.6.

Separately, the Institute for Supply Management’s manufacturing index rose to 60.2% in June from 58.7%. A read on construction spending rose 0.4% in May.

What were strategists saying?

“The increase in the ISM manufacturing index in June is a clear sign that, for now at least, the strength of the domestic economy is more than offsetting any increased uncertainty on trade policy. However, with the dollar appreciating by 6% since April, global growth slowing and retaliatory tariffs just beginning to bite, the [manufacturing] sector looks unlikely to fare so well for long,” Michael Pearce, senior U.S. economist at Capital Economics, said in a note.

“This is usually a slow week with the holiday, but there’s definitely color in the market that is causing it to be volatile,” Mark Esposito, president of Esposito Securities, a Dallas-based asset manager.

“When Trump starts talking about the WTO, China, all these big economies and these big threats, the market is going to react to that. It creates turmoil, and people are getting frustrated with all the back and forth. I think the long-term growth story of the economy remains intact, but in the meantime the trade will can cause a lot of tremors in the short term,” he said.

How Trump Is Tightening His Squeeze on Iran

Which stocks were in focus?

Large-cap tech shares like Micron Technology Inc. MU, -0.88% , Nvidia Corp. NVDA, +2.10% , and Intuitive Surgical Inc. ISRG, -0.27% were notable gainers, helping the Nasdaq outperform the S&P 500 and the Dow. Micron rose 3.9%, Nvidia gained 2.3%, and Intuitive Surgical added 2%.

Auto-industry players such as General Motors Co. GM, -1.04% and Ford Motor Co. F, +0.22% were in focus on trade concerns. GM on Friday warned the Trump administration that tariffs on vehicle imports would hurt its competitiveness, cost U.S. jobs and result in “a smaller GM.”

Other major auto makers joined GM in comments to the U.S. Department of Commerce, including Toyota Motor Corp. TM, -0.95% 7203, -2.16% , which warned Friday that auto tariffs “would have a negative impact on all manufacturers.”

GM and Ford reversed earlier losses to finish higher but Toyota shares were down 1.4% in Tokyo.

United Rentals Inc. URI, +2.71% agreed to acquire BakerCorp International Holdings Inc. for about $715 million in cash. Shares fell 1.9%.

Alkermes PLC ALKS, -2.25% rose 1.8% after the U.S. Food and Drug Administration approved its long-acting injectable atypical antipsychotic for the treatment of schizophrenia in adults.

Adamis Pharmaceuticals Corp. ADMP, -5.21% jumped 50% after it announced a distribution and commercialization agreement with Novartis AG’s NVS, -1.44% Sandoz Inc. unit.

Compugen Ltd. CGEN, -4.96% jumped 4.6% after the U.S. Food and Drug Administration lifted a clinical hold on its investigational new drug application for an immuno-oncology therapeutic antibody.

How did other markets fare?

European stocks SXXP, -1.02% fell sharply along with Asian markets.

Oil futures US:CLQ8 settled lower after a weekend tweet from Trump hinted at a big potential production increase from Saudi Arabia. Gold futures US:GCQ8 settled 1% lower as the ICE U.S. Dollar Index DXY, -0.02% gained.

—Victor Reklaitis contributed to this article