The Dow Jones industrial average rose 46.34 points to 23,979.10, with Merck and Intel as the best-performing stocks in the index.
Stocks closed well off their session highs on Monday as shares of Amazon and Boeing rolled over. Traders said a report that FBI officers had raided the office of President Donald Trump's personal lawyer also fueled the late-day decline.
The Dow Jones industrial average rose 46.34 points to 23,979.10, with Merck and Intel as the best-performing stocks in the index. The S&P 500 gained 0.3 percent to close at 2,613.16, with tech surging 0.8 percent. The Nasdaq composite advanced 0.5 percent to 6,950.34.
Amazon shares had risen as much as 2.3 percent before closing just 0.1 percent higher. Boeing gained as much as 2.7 percent before ending the session down 1.1 percent.
At its session high, the Dow rose as much as 440.42 points. Meanwhile, the S&P 500 and Nasdaq gained as much as 1.9 percent and 2.3 percent, respectively.
"It's certainly sending it down into the close," said Andrew Brenner of National Alliance Securities, about the report, which was later confirmed by NBC News. "I think the equities market was having its own negative momentum."
The New York Times reported the FBI raided Michael Cohen's office. Cohen is Trump's longtime personal lawyer.
Stocks rallied earlier after the US had slightly softened its tone against China. Treasury Secretary Steven Mnuchin told CBS on Sunday he does not expect a trade war between the US and China to take place. Mnuchin made his comments after telling CNBC's "Power Lunch" on Friday that a trade war between the two largest world economies was possible.
Trump himself said in a tweet Sunday: "President Xi and I will always be friends, no matter what happens with our dispute on trade. China will take down its Trade Barriers because it is the right thing to do. Taxes will become Reciprocal & a deal will be made on Intellectual Property. Great future for both countries!"
Last week, China announced fresh tariffs on 106 US products, which then saw Trump going on to threaten more levies, saying that he had asked the United States Trade Representative to consider USD 100 billion in additional tariffs against the Asian nation.
The trade news left Wall Street on edge last week, with the S&P 500 falling more than 1 percent in the time period. The Dow and Nasdaq also declined last week.
"There are two important conflicting signals right now emanating from the White House: The pro-business signal has been powered by deregulation and tax cuts. The protectionist signal raises the prospects of a trade war, which would be bad for business," Ed Yardeni, president and chief investment strategist at Yardeni Research, wrote in a note Monday.
"[W]e are going to stick with the bullish signal for business, as most clearly measured by S&P 500 earnings. We expect it will prevail over the bearish signal, which we expect will soon turn into background noise," Yardeni said.
The next corporate earnings season kicks off later in the week with financial companies BlackRock, Citigroup, J.P. Morgan Chase and Wells Fargo all scheduled to release their quarterly results.
"First quarter earnings season is almost here, and the results/guidance should be very good," said Nicholas Colas, co-founder of DataTrek Research, noting Wall Street is expecting first-quarter earnings to grow by 17 percent.
In corporate news, Merck rose more than 6 percent after a committee determined Keytruda has helped previously untreated lung cancer patients live longer.
Facebook climbed 1.3 percent ahead of CEO Mark Zuckerberg's testimony on Tuesday regarding the data scandal involving firm Cambridge Analytica.