The S&P 500 index and the Dow Jones Industrial Average closed lower Wednesday as the resignation of top White House economic adviser Gary Cohn stoked fears of a trade war but the tech-laden Nasdaq bucked the trend to extend its winning streak to a fourth session.

Concerns about the prospect of a global trade war, prompted by Trump’s plan to introduce tariffs on steel and aluminum imports, intensified as Cohn had opposed the tariff proposal and was widely viewed as having a moderating influence within the White House.

Still, some of the selling pressure eased following the release of the Federal Reserve’s beige book, which emphasized modest economic growth and moderate inflation, helping the indexes to bounce off intraday lows.

Read more:How a tariff-rattled stock market is reacting to Cohn’s resignation

And see:Trump tariffs may really be a backdoor way to get out of the WTO

How did the main benchmarks fare?

The Dow Jones Industrial Average DJIA, -1.84% slid 82.76 points, or 0.3%, to 24,801.36. Earlier, the blue-chip gauge was off more than 300 points.

The S&P 500 SPX, -1.15% shed 1.32 points to 2,726.80. Energy stocks were big losers as crude oil futures US:CLJ8 sank nearly 2% on worries about mounting trade friction.

The Nasdaq Composite Index COMP, -0.13% rose 24.64 points, or 0.3%, to 7,396.65.

Small-capitalization stocks defied the general weak trend with the Russell 2000 RUT, -3.42% up 12.33 points, or 0.8%, to 1,574.53. Small-caps have relatively less exposure to international trade than their large cap peers.

What drove the markets?

Investors were nervous, fleeing assets perceived as more risky after the news of Cohn’s resignation. He is regarded as the chief architect of Wall Street-friendly corporate tax cuts signed into law last year, and he was seen as a level head in an administration that has seen tumult.

Check out:Meet Peter Navarro, the man who pushed Gary Cohn out of the White House

His decision to leave the role as the president’s top economic adviser adds to fears that Trump is adopting an increasingly protectionist stance and could spark a global trade war. That type of conflict could threaten the U.S. economic growth and corporate earnings.

See:How stock-market investors are bracing for a potential trade war after Cohn exit

And read:Why a full-blown Trump trade war won’t happen

The European Union said Wednesday it is discussing which American products it would hit with tariffs if Trump moves ahead with his plan. In addition, the Trump administration is reportedly considering a broad range of import tariffs on Chinese goods.

Don’t miss:EU leader responds to Trump’s tariff plan: ‘We can also do stupid’

“Prices increased in all districts…[and] most districts saw employers raise wages and expand benefit packages in response to tight labor market conditions,” according to the beige book. However, overall wage and price growth were viewed as “moderate,” suggesting that the Fed has some breathing room before turning more hawkish. The recent pick up in prices have triggered concerns that the central bank could hike rates four times this year versus three as previously telegraphed.

What were strategists saying?

“It is not so much the resignation, but the role that Cohn has played in the administration. He was seen as the voice of economic stability and a spokesperson for financial markets,” said Brad McMillan, chief investment officer for Commonwealth Financial Network, in a note to investors. “His resignation leaves the president with a set of economic advisers largely seen as outside of the mainstream, or at least perceived as less aligned with Wall Street interests. At a minimum, this introduces more uncertainty into economic policy and raises the chance of policy actions such as tariffs.”

“The market is waiting for more details about the tariffs, but the more specifics we get the more chances that trading partners will come with retaliatory response,” said Quincy Krosby, chief market strategist, at Prudential Financial.

“In the absence corporate earnings news, and with weeks before the next Fed meeting, markets have more time to react to headline news from Washington. We expect market reaction to news who will replace Cohn,” Krosby said.

Read:Peter Navarro says he’s not on list to replace Gary Cohn

Caroline Baum:No one should replace Gary Cohn; Trump should abolish the job

Much will depend on who Trump chooses to replace Cohn and if his successor is deemed to be in favor of free trade like Cohn, then that can be viewed as a market-friendly outcome, said Fawad Razaqzada, a Forex.com analyst. However, if the new person is a trade hawk, then it could fuel further uncertainties in the market.

Read more:Slumping stocks may ‘test the February lows’—analysts react to Cohn’s exit

What was on the economic docket

A hefty lineup of releases kicked off with the ADP employment report for February.

Private-sector employers added 235,000 jobs in February, while the initial January gain of 234,000 was raised by 10,000 in the latest data. February is the fourth month in a row where job gains were 200,000 or higher.

The U.S. trade deficit climbed 5% in January and hit a nearly 10-year high, continuing a steady rise since President Trump took over that could exacerbate already tense disputes between the administration and key trading partners.

Updated numbers show that the fourth-quarter productivity was flat and unit labor costs were raised to 2.5% from 2%.

Check out:MarketWatch’s Economic Calendar

Which stocks were in focus?

Shares in H&R Block Inc. HRB, +1.94% jumped 12% after the tax preparer reported late Tuesday a wider-than-expected fiscal-third-quarter 2018 loss but quarterly revenue that came in above expectations.

Urban Outfitters Inc. URBN, -4.01% late Tuesday reported fourth-quarter earnings that took a hit from the new U.S. tax law. The retailer’s stock reversed earlier losses to rise 0.2%.

Autodesk Inc. ADSK, +1.11% shares rallied 15% after the company posted fourth-quarter net losses and revenue late Tuesday that beat expectations.

Ross Stores Inc. ROST, -2.00% beat fourth-quarter sales and earnings expectations in its results, but predicted a slower-than-expected pace of same-store sales growth for the year. The retailer’s stock was down 6.4%.

Dollar Tree Inc. DLTR, -2.32% shares slumped 15% after the retailer released its earnings.

How did other markets perform?

European stocks SXXP, -3.24% mostly gained and Asian markets closed lower across the board.

The ICE U.S. Dollar Index DXY, +0.68% was flat and gold futures settled weaker.

—Mark DeCambre, William Watts, Victor Reklaitis, Karen Friar and Barbara Kollmeyer contributed to this article.