U.S. stocks ended mostly higher on Friday, with the S&P 500 and the Nasdaq erasing an early decline to end higher as investors viewed the reaction to an announcements of tariffs as overdone.

The Dow, however, fell for a fourth straight session and major indexes suffered sharp weekly losses. Much of that weakness came after President Donald Trump on Thursday announced tariffs on steel and aluminum imports, and subsequently escalated the rhetoric around a potential trade war, considered a major political risk for markets.

What are the main benchmarks doing?

The Dow Jones Industrial Average DJIA, -2.88% fell 70.92 points, or 0.3%, to finish at 24,538.06, after earlier falling as much as 391 points. Blue-chip component McDonald’s MCD, -2.34% was the biggest drag on the average, falling 4.8%, for its biggest one-day percentage drop since October 2008.

Read:Here’s what the 30 Dow industrials companies say about a potential trade war

The S&P 500 SPX, -2.19% rose 13.58 points, or 0.5%, to end at 2,691.25. The Nasdaq Composite Index COMP, -1.38% rose 77.31 points, or 1.1%, to 7,257.87.

The Dow’s four-day decline marks its first such streak since September. Both the blue-chip average and the S&P are coming off three straight sessions with a 1% decline, their longest such streak since January 2016.

For the week, the Dow fell 3.1%, the S&P lost 2% and the Nasdaq shed 1.1%.

The Russell 2000 index RUT, -3.93% of small capitalization shares rose 1.7% and had its biggest one-day percentage jump in about two weeks. Small-cap stocks are seen as less vulnerable to trade issues, as the components typically have lower exposure to revenue from outside the U.S.

Don’t miss: These Dow and S&P 500 stocks took the biggest hits on fears of a Trump trade war

Worries over the prospect of a global trade war have rattled markets since the tariff announcement, furthered by a Friday tweet from the president that “trade wars are good, and easy to win.” Some of the U.S.’s biggest trading partners have already threatened to retaliate, including the European Union, which has said it’ll take the matter to the World Trade Organization.

The prospect of increased trade protectionism—long cited as a primary political risk to stocks this year—was just the latest catalyst for volatility to return to markets in a pronounced fashion. The Cboe Volatility Index VIX, +11.22% rose 18% over the week and is up more than 75% over the course of 2018. However, it fell 14% on Friday, losing ground as equities broadly recovered.

Read: Here’s why the stock market took the Trump tariff announcement so hard

Recent spikes in volatility have come as investors digest the prospect of inflation returning to markets, and the possibility that the Federal Reserve would have to become more aggressive in raising interest rates to combat such an environment.

The inflation concerns led to the first correction for the Dow and S&P in about two years, defined as a 10% drop from a recent peak. At current levels, the Dow is 7.8% below its record, while the S&P is down 6.3% from its peak and the Nasdaq is 3.3% below its own.

What is driving the markets?

Trump on Thursday said he would sign orders next week imposing a 25% tariff on steel imports and a 10% tariff on aluminum. “You’ll have protection for a long time,” Trump told steel industry executives. Many U.S. companies use steel and aluminum in their production, such as airplane makers and beverage companies.

Tariffs can push up the cost of goods, which in turn lifts the selling price or reduces profits, if the manufacturer absorbs the costs. Such trends could amplify market concerns about inflation, which have been a primary driver behind market direction in recent weeks, typically to the downside.

The ICE U.S. Dollar Index DXY, +0.88% fell 0.4% to 89.93 on tariff concerns.

How we got here: A history of U.S. steel wars before Trump

Check out:Trump steel tariffs to hit these 8 countries the hardest (China is not one of them)

Traders were also assessing Federal Reserve Chairman Jerome Powell’s second round of congressional testimony on Thursday. The new central bank boss struck a less hawkish tone than during his appearance on Tuesday, but was still seen as leaving the door open for four rate rises in 2018.

What are strategists saying?

“Tariffs will have an economic impact, although I think it will be marginal in the scheme of things. However, there is a direct correlation with the tariff issue and worries about inflation, which is obviously a concern, and which we hadn’t seen anything resembling for a long time,” said Rich Guerrini, chief executive officer of PNC Investments, which has about $50 billion in assets under management.

Referring to how equities came off their lows of the session on Friday, he called Thursday’s selloff “an overreaction to volatility, which we haven’t experienced in 18 months.” He described Wall Street as being “out of shape,” adding, “if you’re not exercising, then it’ll hurt when you have to do something, and that’s basically what we saw in stocks when the topics of inflation and tariffs came up.”

Matt Forester, chief investment officer of BNY Mellon’s Lockwood Advisors, warned that increased protectionism “could dry up foreign trade and exacerbate the inflation fears we’ve already been experiencing, which is really the key message. This is coming on top of all the other things we were already worrying about.”

Despite that, Forester found some room for optimism, citing recent economic data. A final reading on consumer sentiment for February marked the second-strongest that it has been in 14 years, though it was a touch to 99.7, and lower than estimates for a reading at 100.

“While trade and inflation are big concerns, there are also a lot of good things on the market’s mind,” Forester said. “We’ve been seeing a lot of good data and we’re also getting very attractive earnings growth.”

See:MarketWatch’s economic calendar

Which stocks are in focus?

The decline for McDonald’s came after a research note from RBC Capital Markets cut its U.S. same-store expectations.

Shares of Foot Locker Inc. FL, -5.42% tumbled 12.7% after the athletic shoe and apparel retailer missed sales expectations and provided a downbeat outlook.

Shares of Gap Inc. GPS, -3.48% rallied 7.8% and Splunk Inc. SPLK, -0.22% climbed 9.3% after both companies posted better-than-expected fourth-quarter sales late Thursday.

Ambarella Inc. AMBA, -2.85% gained 13.5% after the semiconductor company’s fourth-quarter earnings out late Thursday beat forecasts.

Nutanix Inc. NTNX, -1.63% rose 7.4% after the enterprise cloud computing company’s quarterly results and outlook out late Thursday topped Wall Street estimates.

American Outdoor Brands Corp. US:AOBC rose 3.6%, erasing an early decline. The Smith & Wesson parent said it expects weak firearm sales for at least a year. The stock has lost half its value over the past 12 months.

What are other markets doing?

Asian stocks closed lower, with Japan’s Nikkei index NIK, +0.17% losing 2.5%. Japanese shares were hit by a rally in the yen after Trump’s tariff announcement and as Bank of Japan Governor Haruhiko Kuroda said the central bank would start thinking about exiting its massive stimulus program in 2019.

European stocks also traded sharply lower, with the Stoxx Europe 600 index SXXP, -3.24% down 1.5%.

Crude-oil prices US:CLJ8 rose 0.7%, while gold futures US:GCJ8 rallied 1.4%.

Read: Opinion: 5 ETFs that nervous investors can use as insurance against a stock-market crash