U.S. stocks closed higher Monday, with the Dow Jones Industrial Average bouncing back from a four-session losing streak, as investors looked beyond the threat of a global trade war and instead focused on positive economic data.

A technical rebound following a stretch of weakness for equities also helped to support broad market gains.

What did the main benchmarks do?

The Dow DJIA, -3.04% bounced back from an earlier decline to rise 336.70 points, or 1.4%, to 24,874.76.

The S&P 500 index SPX, -2.47% rose 29.69 points, or 1.1%, to 2,720.94, with all 11 subsectors finishing higher, led by utilities and financials. The Nasdaq Composite Index COMP, -1.63% added 72.84 points, or 1%, to 7,330.70.

Last week, stocks logged hefty losses, with the Dow dropping 3% and notching its fourth-straight-session loss on Friday. The S&P 500 shed 2% for the week and the Nasdaq declined 1.1%.

Read:Trade-war fears cast shadow over stock market

Plus:Worried about a trade war? Stock-market investors should think small

What drove the markets?

Rattling some investors was news that Sunday’s Italian election is expected to end in a hung parliament, as populist euroskeptic parties made a better showing than forecast. That is seen as signaling a protracted period of political uncertainty for the eurozone’s third-biggest economy.

Read:Italy’s election resulted in political gridlock as expected—what that means for stocks

But in Germany, Social Democrats voted to support a grand coalition government. That means Chancellor Angela Merkel will serve a fourth term and the country is set to have a government after more than five months of uncertainty.

Read:Italy’s election, Germany’s coalition highlight fragile EU

Fears over the potential for global trade war continued after President Donald Trump said last week he will impose a 25% tariff on steel imports and a 10% tariff on aluminum. Those metals are used for products such as airplanes and beverage containers, and tariffs raise fears of an increase in selling prices or reductions in profits for U.S. corporations in those industries.

Read:Trump’s tariffs will hurt the 6.5 million U.S. workers at steel-consuming manufacturers

Trump continued to tweet on the subject over the weekend, at one point threatening to slap a tariff on European autos, should the European Union try to retaliate to the new tariffs. He tweeted Sunday evening that the U.S. is “on the losing side of almost all trade deals. Our friends and enemies have taken advantage of the U.S. for many years.”

Trump’s trade adviser, Peter Navarro, on Sunday blamed the media for hyping the possibility of a trade war. Trump on Friday had tweeted that “trade wars are good, and easy to win.”

A senior Chinese official said that government would soon restart discussions with the U.S. on trade disputes, but a White House spokesman said there was no plan for such a meeting.

Read:Trump steel tariffs to hit these 8 countries the hardest—and China isn’t one of them

Meanwhile, Fed Gov. Randall Quarles said that regulators plan to swiftly make substantial changes to the Volcker rule, describing it as “an example of complex regulation that is not working well.” The comments helped to boost financial stocks.

What were strategists saying?

“I see today’s rebound as more of a technical bounce. After two days of declines on big volume last week, stocks are bouncing back today on light volume. This suggests that the bears have backed off for now, allowing the market to recover a bit. We may also be seeing a bit of bargain hunting or short covering,” said Colin Cieszynski, chief market strategist at SIA Wealth Management.

“Right now the drivers of the market is what’s coming put of Washington,” said Randy Frederick, managing director of trading and derivatives at Schwab Center for Financial Research, referring to the trade pact being renegotiated between Canada, the U.S. and Mexico. Frederick said

“We just don’t know what’s going to happen. We don’t know if we are going to get retaliation from our trading partners, we don’t know how this is going to impact [the North American Free Agreement],” he said.

Read:Look beyond the threat of steel tariffs to the 1.8 million jobs that could vanish if Nafta goes

“Markets are still suffering the aftershocks of the recent selloff, with Fed/BOJ hawkish comments and Trump tariffs causing another leg down. We still think strong growth and robust earnings will deliver good equity returns, but the recent volatility is a sign of things to come,” said James Barty, head of global cross asset and European equity strategy at Bank of America Merrill Lynch, in a note to clients.

Which stocks were in focus?

Shares of XL Group Ltd. US:XL surged 29% after French rival AXA SA CS, -3.93% said it would acquire the insurer for $15.3 billion, pending approval from XL’s shareholders and regulators.

Dermira Inc. US:DERM shares plummeted 66% after the company’s acne drug failed to meet the co-primary endpoints of two phase 3 clinical trials.

Walmart Inc. WMT, +0.42% said it is launching meal kits at more than 2,000 of its stores this year. Shares of meal-kit specialist Blue Apron Holdings Inc. APRN, -4.42% were lower following the Walmart news. Walmart gained 1.4%, while Blue Apron fell 5.1%.

Amazon.com Inc. AMZN, -2.28% shares were in the spotlight amid reports that it is in talks with banks, including JPMorgan Chase & Co. JPM, -3.99% , about building a checking-account services. Shares of Amazon reversed earlier losses to rise 1.6%.

What are economic data saying?

The Markit services purchasing managers index for February came in at 55.9, compared with 53.3 that was expected and 59.9 in the previous month.

Meanwhile, the more closely watched Institute for Supply Management’s nonmanufacturing index for February slipped to 59.5 from 59.9 a month earlier — a level that still signals rapid growth in service-sector activity.

How did other markets fare?

European stocks SXXP, -3.24% closed mostly higher, with the exception of Italian equities XX:I945, on uncertainty surrounding the weekend election. The euro was under pressure, particularly against the yen EURJPY, -0.50% .

Asian markets ended mostly lower, led by a 2.3% drop for Hong Kong’s Hang Seng Index HSI, -2.06% . However, mainland China stocks SHCOMP, -0.63% rose as the National People’s Congress got under way, with officials laying out plans to keep growth steady at about 6.5% this year.

Can simulation stop medical errors, the third-leading cause of death?

Crude-oil prices US:CLJ8 rallied, while gold futures US:GCJ8 settled slightly lower.

—Barbara Kollmeyer contributed to this report