The Dow rose to close above the 25,000 mark Thursday for the first time in nearly two weeks as U.S. stocks finished higher for a fifth straight session in volatile trade.

Wall Street opened solidly higher but subsequently lost ground before recouping losses, supported by the latest data on inflation and the labor market, which pointed to an economy that was growing but in no imminent danger of overheating. Strong results at Cisco also highlighted how American corporations continue to fare well in the current environment.

How did the main benchmarks perform?

The Dow Jones Industrial Average DJIA, -0.87% rose 306.88 points, or 1.2%, to 25,200.37. The S&P 500 SPX, -1.11% added 32.57 points, or 1.2%, to 2,731.20. The Nasdaq Composite COMP, -1.07% gained 112.81 points, or 1.6%, to 7,256.43.

So far this week, the Dow and the S&P are both up more than 4% and on track for their biggest weekly percentage rise since November 2016. The Nasdaq is up over 5%, which represents its best week since October 2014.

Those gains come after sharp losses seen earlier this month, which pushed the Dow and S&P into correction territory, or a 10% drop from a peak. The three gauges stand between 4% and 6% below last month’s all-time highs. The selloff was sparked in part by rising bond yields amid signs of an uptick in inflation, with the higher yields luring money out of equities. Strategists have said the selloff was overdue, but was excessive.

Read more:Don’t be scared by rising inflation and weak retail sales

Don’t miss:Here’s a 10-step plan the stock market must complete to get back on track

What were strategists saying?

“This is a year of recalibration. In January we recalibrated to higher earnings, and now we’re doing it for higher bond yields, which have been led by potentially higher inflation,” said Leo Grohowski, chief investment officer of BNY Mellon Wealth Management. “Market participants are correctly focusing on inflation, because a rise in inflation can preface an economic slowdown, or an increase in interest rates that could lead to one.”

Grohowski remains optimistic about the market, noting that his firm’s year-end target for the S&P 500 was 2,850. However, he expects the recent volatility to persist as investors struggle between the prospect of higher rates on one hand and strong fundamentals on the other.

“This tug of war will be with us for the year, but I think the market is becoming more comfortable with the idea that a little bit of inflation will be OK,” said Grohowski, who helps oversee $238 billion in total client assets.

”Volatility could remain a staple of the markets in 2018, but there is no need to panic. Non-recessionary market pullbacks tend to be relatively short-lived, while major one-day market selloffs, historically, are typically followed by better-than average returns,” Joe Quinlan, head of thematic strategy at Bank of America Global Wealth and Investment Management, said in a note to investors.

Quinlan shared the following chart which shows how market declines tend to be short-lived when the economy is not in a recession.

Market peaks from 1945-2017

Bank of America Global Wealth and Investment Management

What drove the markets?

In the latest economic data, initial jobless claims rose 7,000 to 230,000 in the latest week, as had been expected, but claims remain near multidecade lows. Separately, wholesale prices rose 0.4% in January, led by a rise in oil prices, though core producer prices were also up by 0.4%. The figure was the latest view on inflation, following Wednesday’s consumer-price index.

Two gauges of manufacturing sentiment underscored solid growth in February. The Philadelphia Fed manufacturing index rose to 25.8 in February from 22.2 in January. Economists had expected a slight retreat to 21. The Empire State Index, meanwhile slowed to 13.1 in February from 17.7 in January, the New York Fed said. While the Empire State index was well above the level indicating improving conditions, this was a weaker reading than had been anticipated.

Mortgage rates have climbed to the highest level in close to four years, according to data released Thursday.

See:MarketWatch’s Economic Calendar

What were other assets doing?

European stocks SXXP, -0.66% closed in positive territory across the board, while Asian markets were sharply higher, though volumes in much of the region were capped with some Asian markets closed for the Lunar New Year holiday.

The ICE U.S. Dollar Index DXY, +0.03% was off 0.6%, oil futures US:CLH8 rose more than 1% and gold US:GCG8 settled moderately lower.

Check out:Why the U.S. dollar found no love despite stronger-than-expected inflation

Which stocks were key movers?

Shares in Cisco Systems Inc. CSCO, -1.38% jumped 4.7% for the biggest gain among Dow components. The tech giant’s earnings and outlook topped Wall Street estimates late Wednesday, and the company also showed revenue growth for the first time in more than a year and a half. The stock has gained more than 13% thus far this year, making it the second-best performer among Dow stocks, behind Boeing Co. BA, -3.81% .

Read:Cisco turns corner in tough transition to a new era

And see:Cisco is ‘putting together newer growth engines’—analysts react to earnings

Apple Inc. AAPL, -3.17% rose 3.4% on news that Warren Buffett’s Berkshire Hathaway Inc. raised its stake in the iPhone maker by 31.24 million shares to 165.33 million shares at the end of December.

Shares in TripAdvisor Inc. TRIP, -1.65% climbed 4.1% after the online travel company posted better-than-expected earnings late Wednesday.

Shares in McDonald’s Inc. MCD, -1.03% advanced 0.5% after the fast-food heavyweight announced a fresh worldwide push to make its Happy Meal offerings healthier, including taking away the cheeseburger as an entree choice in the U.S. “The cheeseburger will only be available at a customer’s request,” the company said in a news release.

Shares in Avon Products Inc. US:AVP jumped 13% after the beauty-products seller posted adjusted quarterly earnings that beat forecasts, but revenue that missed expectations.

AntaresPharma Inc. ATRS, +3.24% rallied 19% while Amag Pharmaceuticals Inc. AMAG, +6.98% surged 29% after Amag said the U.S. Food and Drug Administration has approved their Makena subcutaneous auto injector drug-device combination product.

Meet the robots that aim to revolutionize retail

—Victor Reklaitis contributed to this report