Technology companies powered US stocks to solid gains on Thursday, snapping the market's two-day losing streak.
Banks, consumer-focused companies and industrial stocks also helped lift the market.
Even so, the broad gains, which came on the last day of trading ahead of the Easter holiday weekend, were not enough to make up for the stock market's first quarterly loss since 2015.
After years of slow and steady growth and a roaring start to 2018, the market plunged in early February, marking its first 10% drop in two years.
In the weeks since, the market has been more volatile and trading has frequently turned choppy.
"The equity market is ending the week and the quarter on a positive note, and that's following a quarter that's been volatile and uniformly lacklustre," said Terry Sandven, chief equity strategist at US Bank Wealth Management.
"We still look for positive trends as we now move into the second quarter, but we think the pace at which equities move will still be muted."
The S&P 500 index rose 35.87 points, or 1.4%, to 2,640.87.
The Dow Jones industrial average gained 254.69 points, or 1.1%, to 24,103.11.
The blue chip average was briefly up 465 points. The Nasdaq added 114.22 points, or 1.6%, to 7,063.44.
The Russell 2000 index of smaller-company stocks picked up 16.40 points, or 1.1%, to 1,529.43.
The Dow is down 2.5% for the year, while the S&P 500 is off 1.2%. The Nasdaq is holding to a 2.3% gain.
Sandven said the market's first-quarter performance had tempered expectations for the rest of the year after the market's strong start in January.
"Volatility has ramped up, inflationary pressures are more prevalent, interest rates are on the cusp of change, so that presents a higher level of uncertainty and higher investor angst," Sandven said.
The major indexes were headed higher from the start of trading Thursday as investors sized up several company earnings reports and new government data showing that spending by US consumers rose 0.2% in February, while their incomes increased 4.4%.
The healthy income gains could spur more spending in the coming months.
Technology stocks, which were big decliners earlier in the week, powered much of the market's climb Thursday.
Facebook was among the gainers, its shares adding 4.4%. The social media giant, which has taken a beating in recent days over privacy concerns, rose 6.76 dollars, to 159.79 dollars.
Even with the roller-coaster ride that technology stocks have been on lately, the sector is up 3.2% this year, while most other sectors are in the red.
Thursday's run-up in technology stocks signalled that investors believe the sector was oversold in recent weeks, said Sandven, adding that perhaps some of it could be explained by some fund managers padding portfolios with stocks to elevate their quarter-end results, what Wall Street calls "window-dressing".
Shares in several companies that reported improved quarterly earnings or outlooks got a boost.
PVH, which owns Calvin Klein and Tommy Hilfiger, climbed 7.41 dollars, or 5.1%, to 151.43 dollars, while beverage maker Constellation Brands rose 7.43, dollars or 3.4%, to 222.92 dollars.
Solid results and a better-than-expected outlook also gave Movado Group shares a lift. The watchmaker's stock jumped 5.20 dollars, or 15.7%, to 38.40 dollars.
Some companies had a rough day, even after delivering strong quarterly results.
Gamestop slumped 10.8% after the retailer issued a disappointing full-year revenue and earnings outlook, which overshadowed fourth-quarter results that beat Wall Street's expectations. The stock slid 1.53 dollars to 12.62 dollars.
The fallout from the heightened scrutiny on how social media portals use consumers' personal data weighed on Acxiom shares.
The marketing data firm's stock tumbled 19% after it disclosed that Facebook would cease using third-party data providers like Acxiom over the next few months.
Acxiom said it did not expect the move to affect its fiscal 2018 guidance, but noted it expected its total revenue and profitability to be negatively affected by as much as 25 million dollars. Acxiom declined 5.34 dollars to 22.71 dollars.
Bond prices rose. The yield on the 10-year Treasury fell to 2.74% from 2.78% late Wednesday.
US stock markets will be closed for the Good Friday holiday.