"That will lift a major cloud that's over the global economy," he said.

"To a certain degree, a trade deal is already priced in," said Peter Cardillo, chief market economist at Spartan Capital Securities. However, "a trade deal is a win for the United States and the global economy."

Chipmakers — which are heavily affected by U.S.-China trade relations — led the tech sector higher. The VanEck Vectors Semiconductor ETF (SMH) climbed 2.3%, led by an 8.5% surge in Advanced Micro Devices. AMD jumped after Nomura Instinet initiated coverage of the stock with a buy rating , citing the company's improving profitability.

The Dow Jones Industrial Average climbed 39 points to close at 26,218.13 as Intel and Home Depot outperformed. The gained 0.2% to end the day at 2,873.40, notching a five-day winning streak, as the materials and tech sectors led the way. The Nasdaq Composite advanced 0.6% to 7,895.55.

Stocks rose slightly on Wednesday as investors cheered a nearing trade deal between the U.S. and China, though softer measures on payrolls and the service economy kept a lid on optimism.

Traders work on the floor of the New York Stock Exchange (NYSE) in New York, U.S., December 27, 2018.

American and Chinese officials are reportedly closing in on a trade deal, having resolved most of the outstanding issues in their protracted trade dispute. Both countries have levied tariffs on billions of dollars' worth of each other's goods since last year.

According to the Financial Times, Beijing wants Washington to remove existing U.S. duties on Chinese imports, while the Trump administration wants China to agree to enforcement measures that ensure the country sticks to the deal.

U.S. Trade Representative Robert Lighthizer and Treasury Secretary Steven Mnuchin are scheduled to meet with Chinese Vice Premier Liu He later on Wednesday to resume talks.

European stocks rose broadly as the Stoxx 600 index gained 1%. In Asia, the Shanghai Composite surged 1.2%, while the Japanese and Korean Kospi indexes both rose around 1%.

"I think there's more buzz about getting closer to the finish line on a trade deal than there is on the direction of the economic data stream," said Art Hogan, chief market strategist at National Securities. "If we're catching a bid both domestically and overseas, I think it means we're probably close to the end of that drama."

However, weaker-than-expected economic data kept gains in check.

Growth in services fell more than expected in March and advanced at its slowest pace in more than 12 months, the Institute for Supply Management reported. The ISM non-manufacturing index dipped to 56.1 last month, its softest read since August 2017.

"We know manufacturing has slowed both in the US and globally while the services side has helped to offset this," said Peter Boockvar, chief investment officer at Bleakley Advisory Group. "But one can't outperform for long while the other is challenged. Is this moderation in services the first sign that the softness in manufacturing is now impacting services? Maybe.

Private payrolls increased by 129,000 in March, according to ADP and Moody's Analytics. That is well below a Refinitiv estimate of 173,000. The report from ADP and Moody's is typically seen as a preview for the U.S. government's monthly jobs report, which is scheduled for release Friday morning.

A bearish call on Caterpillar shares also kept market gains in check. Caterpillar shares fell 0.7% after Deutsche Bank downgraded the industrial giant to hold from buy and slashed its 12-month price target. The bank cited a "collapse" in synchronized global growth.

—CNBC's Ryan Browne contributed to this report.