NEW YORK (Reuters) - Wall Street rallied on Tuesday as investors were heartened by a tentative congressional spending deal to avoid another partial federal government shutdown and by optimism surrounding U.S.-China trade negotiations.

All three major U.S. stock indexes posted their biggest one-day percentage gains for the month so far, each advancing more than 1 percent. The S&P 500 ended the session above its 200-day moving average for the first time since early December.

President Donald Trump said he would be willing to let the March 1 tariff deadline slide as top U.S. officials arrived in Beijing for high-level talks later in the week to hammer out a solution to the trade dispute between the world’s two largest economies.

Congressional negotiators cobbled together a tentative bipartisan border security deal late on Monday to avert another partial government shutdown. However, Trump on Tuesday expressed displeasure with the agreement and said he had yet to decide whether to support it. Funding for the Department of Homeland Security and a host of other agencies is due to expire on Friday.

“It’s a combination of hopes that (a) government shutdown is not going to happen and maybe the March 1 (tariff) deadline isn’t so firm,” said Stephen Massocca, senior vice president at Wedbush Securities in San Francisco. “People were concerned we were going to see a dramatic increase in tariffs, and those fears have been somewhat allayed.”

The fourth-quarter earnings season is nearing the home stretch, and 71 percent of S&P 500 companies that have reported have beaten consensus estimates.

The outlook for 2019, however, is less rosy. First-quarter earnings are now expected to post a year-on-year decline of 0.3 percent, which would be the first loss since the earnings recession ended in the second quarter of 2016.

The Dow Jones Industrial Average rose 372.65 points, or 1.49 percent, to 25,425.76, the S&P 500 gained 34.93 points, or 1.29 percent, to 2,744.73 and the Nasdaq Composite added 106.71 points, or 1.46 percent, to 7,414.62.

Tuesday’s rally was broad-based. Of the 11 major sectors of the S&P 500, all but real estate closed in positive territory. Technology stocks provided the biggest boost to the S&P 500, and they also led the Nasdaq’s advance.

Tariff-sensitive industrials headed up the Dow’s gain, led by 3M Co, Caterpillar Inc, United Technologies Corp and Boeing Co.

Amazon.com Inc provided the biggest lift to the S&P 500 and the Nasdaq, rising 3.0 percent after Walmart Inc ended its partnership with logistics firm Devi for a rival same-day grocery delivery service.

Electronic Arts Inc announced that its Apex Legends video game has signed up 25 million players in the week since its release, sending its stock up 5.2 percent. The video game maker’s shares have soared by nearly 28 percent since the game’s release.

Under Armour Inc jumped 6.9 percent after the sportswear company beat analysts’ profit forecasts for the holiday quarter.

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

The S&P 500 posted 43 new 52-week highs and one new low; the Nasdaq Composite recorded 71 new highs and 12 new lows.

Volume on U.S. exchanges was 7.09 billion shares, compared with the 7.45 billion-share average over the last 20 trading days.