The Dow Jones industrial average rose sharply on Thursday, posting its sixth straight day of gains, following the release of weaker-than-expected U.S. inflation data.

Exxon Mobil and UnitedHealth were the best-performing stocks in the 30- stock index, which closed positive for 2018. The Dow rose 196.99 points to close at 24,739.53.

Meanwhile, the S&P 500 gained 0.9 percent to 2,723.07, with utilities and telecom both rising more than 1 percent. The Nasdaq composite advanced 0.9 percent to close at 7,404.97 as Apple reached an all-time high.

Technology shares also aided the broader indexes. The sector rose about 1.3 percent, as shares of Apple, Facebook, Amazon and Google-parent Alphabet all closed higher.

"Inflation is gradually rising, but it's less likely to feed into the volatility we've seen recently," said Mike Bailey, director of research at FBB Capital Partners. "I also think investors are looking at valuations and realize they are pretty reasonable."

The Labor Department said before the open its consumer price index rose 0.2 percent in April, with economists polled by Reuters expecting a 0.3 percent bump. The lighter-than-forecast number eased concerns about the Federal Reserve tightening monetary policy at a faster rate than the market is expecting.

Brendan McDermid | Reuters

Traders work on the floor of the New York Stock Exchange (NYSE) in New York, U.S., November 30, 2017.

"This was a far cry from the great leap many inflation alarmists have been fearing. We're still well within the Fed's 2% comfort level, so some will say we're right where we need to be," said Mike Loewengart, vice president of investment strategy at E-Trade, in an email. "Within the context of a strong economy that has been gaining momentum, this type of modest inflation growth is likely to be a crowd pleaser."

As of Thursday, market expectations for rate hikes in June and September are 100 percent and 76 percent, respectively, according to the CME Group's FedWatch tool. This is in line with the Fed's interest-rate projections released in March, when the central bank last raised rates.

The Labor Department also reported Thursday that weekly jobless claims remained near a 48-year low at 211,000.

The moves Thursday after U.S. stocks posted strong gains in the previous session, boosted by a strong uptick in crude futures. Oil prices have been on the rise since Tuesday, when the U.S. announced that it would be withdrawing from the Iran nuclear accord set in place in 2015.

Energy stocks have been rising along with oil. The sector is up more than 9 percent in the past month. But Derek Green, wealth adviser at Titus Wealth Management, said he would "fade" the rally at this point. "We're in the seasonal period where energy starts to peak," he said. "Moving forward, you want to get more defensive as we get closer to the midterm elections."

In corporate news, Booking Holdings dropped more than 4.5 percent after giving weaker-than-expected quarterly guidance. The company reported better-than-forecast earnings and revenue for the previous quarter, however.