U.S. markets trimmed 2018 losses in a Monday rally, but it was not enough to prevent the worst yearly decline for stocks since 2008.

All three major indexes finished 2018 in the red during the finale of a tumultuous year. The Dow Jones industrial average closed the last day of 2018 at 23,32.467, up 265.06 points, or 1.1 percent, on the day. The Dow finished at negative 5.97 percent for the year.

The Standard & Poor’s 500-stock index ended Monday at 2,506.85, up 21.11 points, or 0.85 percent. It closed 2018 down 6.24 percent on the year.

The tech-heavy Nasdaq composite index ended the year at 6,635.28, despite a 50.76-point gain, about 0.77 percent. The Nasdaq finished down 4.38 percent for the year.

Monday’s early gains came as reports surfaced that the Trump administration and China were making progress on trade talks. But the markets whipsawed during afternoon hours as a broad set of concerns remained, including a grim manufacturing report out of China, slowing global economic growth, rising U.S. interest rates and a decline in oil prices.

“The markets were troubled all year long and damaged by the trade war and by the apparent economic slowdown,” said John Kilduff of Again Capital. “That was reinforced last night with Chinese manufacturing numbers showing a contraction.”

China’s manufacturing sector contracted for the first time in 2½ years in December, according to a Chinese government report released Monday.

The China slowdown may be tied to President Trump’s trade war. The result is a waning outlook for the global economy.

December was a rough month for markets, with all three indexes plunging around 9 percent as the Federal Reserve continued to tighten money supply, with a quarter-point increase in interest rates.

Nine out of 11 U.S. sectors were in negative territory at the end of Monday’s session, with the energy and materials sectors leading the way downward. Energy companies have been hobbled by a 25 percent decline in oil prices in 2018 due to a supply glut.

Health care and utilities ended as the only two positive sectors for the year.

“The global equity markets need a strong Chinese economy, and it’s faltering,” Kilduff said. “That is weighing heavily on oil and will continue to weigh on stocks into the new year.”

Wall Street analysts will remember 2018 for the return of volatility, which swept back into markets after a remarkably quiet 2017.

“While volatility pales compared to what it was during the recession of 2008-2009, we had gotten used to significantly lower volatility in 2017,” said Howard Silverblatt of S&P Dow Jones Indices.

One measure of market volatility is the intraday swings in stock prices. In 2018 there were 110 market swings of 1 percent in the S&P, compared with only 10 in 2017. That is still 35 percent below the annual average of 169 intraday market swings of 1 percent since 1962.

The volatility began with a steep February sell-off after Trump signaled his intent to impose tariffs on goods such as solar panels and washing machines imported into the United States.

The market eventually adjusted to Trump’s tweets and trade threats, aided by strong corporate earnings and a tax cut. Stocks pushed toward record highs by early autumn.

The market then reversed over the last three months as Fed Chairman Jerome H. Powell said the central bank had embarked on increases to normalize interest rates.

The three-month slide included a dramatic drop in the FAANG stocks — Facebook, Amazon, Apple, Netflix and Google parent Alphabet — and culminated in the worst Christmas Eve market drop in history.

The Christmas Eve sell-off came on the heels of phone calls from Treasury Secretary Steven Mnuchin to major U.S. banks. Instead of calming markets, the un­or­tho­dox phone calls worried investors and the Dow dropped 653 points, or just under 3 percent.

When markets opened Dec. 26, the Nasdaq was deep in bear-market territory and the S&P was close behind. Bear markets are generally measured as a 20 percent retreat from recent highs. All three indexes had descended into a correction, which is a 10 percent decline.

The Dow on Dec. 26 staged a 1,086-point rally, its biggest point gain in history, as the volatility resumed.

Sam Stovall of CFRA, an investment research firm, said people should get used to the turbulence.

“The volatility is back to normal,” said Stovall, CFRA’s chief investment strategist. “We got spoiled in 2017. Interest rates remained relatively low, economic growth was strong and investors were buying stocks in anticipation of the late-2017 tax cut.”

The economy is expected to have finished 2018 with around a 3 percent annual growth rate, which some economists did not think possible. The expected growth rate in 2019 is anywhere from 2 to 2.5 percent.