The S&P 500 lost 6.9 percent in October, while the Nasdaq shed 9.2 percent, its biggest monthly loss since November 2008.
Fears of rising borrowing costs, global trade disputes and a possible slowdown in U.S. corporate profits spooked equity investors this month, with technology and internet names that had powered the market's rally taking the biggest hit.
"People are just happy to have the month of October over," said Peter Tuz, president of Chase Investment Counsel in Charlottesville, Virginia.
"All of the fears that popped up last week are being pushed into the background right now. I don't know if it's going to have any legs to it. Just a few earnings in the next few days can change things a lot."
On Wednesday, shares of Facebook Inc gained 3.8 percent after the social media giant said margins would stop shrinking after 2019 as costs from scandals ease.
The S&P communication services index, which also houses Alphabet Inc and Netflix Inc, rose 2.1 percent. The S&P technology index ended up 2.4 percent on the day.
Shares of Amazon.com Inc and Apple Inc, which is due to report results after the bell on Thursday, climbed as well, by 4.4 percent and 2.6 percent respectively.
The Nasdaq gained 3.6 percent in the last two sessions, its biggest two-day percentage gain since June 2016. General Motors Co shares jumped 9.1 percent to notch their biggest one-day gain since late May, after the No. 1 U.S. automaker posted robust quarterly results and forecast strong full-year earnings.
The Dow Jones Industrial Average rose 241.12 points, or 0.97 percent, to 25,115.76, the S&P 500 gained 29.11 points, or 1.09 percent, to 2,711.74 and the Nasdaq Composite added 144.25 points, or 2.01 percent, to 7,305.90.
The Cboe Volatility Index, the most widely followed gauge of expected near-term gyrations for the S&P 500, had its lowest close since Oct. 23.
The Dow lost 5.1 percent for the month, its biggest monthly percentage decline since January 2016.
October also marked only the 12th time since the start of the current equity bull market that both stocks and U.S. Treasury bonds produced losses in the same month, based on preliminary data.
Mostly stronger-than-expected results have pushed up third-quarter profit growth estimates for S&P 500 companies to 26.3 percent, according to I/B/E/S data from Refinitiv data.
Defensive sectors were the only decliners. The S&P consumer staples index fell 0.9 percent.
Shares of Kellogg fell 8.9 percent after cutting its full-year profit forecast due to higher advertising and distribution costs.
The financial sector rose 1.4 percent and the S&P 500 regional banks index gained 1.9 percent, on the Federal Reserve's proposal to ease regulations for U.S. banks with less than $700 billion in assets.
Advancing issues outnumbered declining ones on the NYSE by a 1.53-to-1 ratio; on Nasdaq, a 1.59-to-1 ratio favored advancers.
The S&P 500 posted 12 new 52-week highs and four new lows; the Nasdaq Composite recorded 38 new highs and 114 new lows.
About 9.8 billion shares changed hands on U.S. exchanges. That compared with the 8.7 billion-share daily average for the past 20 trading days.
(Additional reporting by Shreyashi Sanyal & Sruthi Shankar in Bengaluru; editing by Nick Zieminski, James Dalgleish and Jonathan Oatis)
(This story has not been edited by Devdiscourse staff and is auto-generated from a syndicated feed.)