NEW YORK (Reuters) - U.S. stocks ended the final trading day of the first quarter on a strong note on Friday and the S&P 500 posted its best quarterly gain since 2009, boosted by optimism over the latest round of trade talks between the United States and China.

Traders work on the floor at the New York Stock Exchange (NYSE) in New York, U.S., March 22, 2019. REUTERS/Brendan McDermid

The two sides said they made progress in trade talks that concluded on Friday in Beijing. The talks, aimed at resolving a nearly nine-month trade dispute between the world’s two largest economies, were called “candid and constructive” by Washington.

A Chinese delegation led by Vice Premier Liu He will head to Washington next week for another round of talks.

“The prospect of the trade war ending in the very near term is giving a boost to investor confidence, and in turn, we’re closing the quarter with some pretty good gains,” said Peter Cardillo, chief market economist at Spartan Capital Securities in New York.

The benchmark S&P 500 rose 13.1 percent in the quarter, its biggest quarterly gain since the third quarter of 2009 and its best first quarter since 1998.

Trade-sensitive industrials rose 1 percent, while chipmakers, which have a large revenue exposure to China, also gained, with the Philadelphia chip index up 1.6 percent.

The broader technology sector gained 1 percent.

The Dow Jones Industrial Average rose 211.22 points, or 0.82 percent, to 25,928.68, the S&P 500 gained 18.96 points, or 0.67 percent, to 2,834.4 and the Nasdaq Composite added 60.16 points, or 0.78 percent, to 7,729.32.

For the quarter, the Dow gained 11.2 percent, its biggest quarterly rise since 2013, while the Nasdaq jumped 16.5 percent in its best quarter since 2012.

All three major indexes posted gains of at least 1 percent each for the week and registered gains for the month as well.

Ride-hailing startup Lyft Inc surged more than 20 percent after making its debut on the Nasdaq. The stock ended up 8.7 percent.

Data released on Friday showed U.S. consumer spending barely rose in January and income increased modestly in February, suggesting the economy was losing momentum after growth slowed in the fourth quarter.

Growth fears were triggered last week, when the Federal Reserve abandoned projections for interest rate hikes in 2019 and the U.S. Treasury yield curve inverted for the first time since 2007, historically a harbinger of recession.

However, the yield curve between three-month bills and 10-year notes turned slightly positive on Friday, after being inverted for a week.

White House economic adviser Larry Kudlow told Axios on Friday that the Fed should “immediately” cut interest rates by half a percentage point.

With the first quarter earnings reporting season just about two weeks away, investors are bracing for what may be the first U.S. profit decline since 2016. Analysts expect quarterly earnings to fall 1.9 percent from a year earlier, according to Refinitiv data.

Wall Street will be watching economic data with a laser focus next week after the recent warning signals from Treasury yields.

Advancing issues outnumbered declining ones on the NYSE by a 1.73-to-1 ratio; on Nasdaq, a 1.40-to-1 ratio favored advancers.

The S&P 500 posted 42 new 52-week highs and 2 new lows; the Nasdaq Composite recorded 57 new highs and 47 new lows.

Volume on U.S. exchanges was 7.41 billion shares, compared to the 7.52 billion average for the full session over the last 20 trading days.