NEW YORK (Reuters) - U.S. stocks rebounded for a second day on Wednesday as investors snapped up beaten-down technology and internet favorites and strong company results lifted spirits, even as the S&P 500 closed out its worst month in seven years.

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 FB.O 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 .SPLRCL, which also houses Alphabet Inc GOOGL.O and Netflix Inc NFLX.O, rose 2.1 percent. The S&P technology index .SPLRCT ended up 2.4 percent on the day.

Shares of Amazon.com Inc AMZN.O and Apple Inc AAPL.O, 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.

Traders work on the floor of the New York Stock Exchange (NYSE) near the close of market in New York, U.S., October 31, 2018. REUTERS/Brendan McdDermid

General Motors Co GM.N 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 .DJI rose 241.12 points, or 0.97 percent, to 25,115.76, the S&P 500 .SPX gained 29.11 points, or 1.09 percent, to 2,711.74 and the Nasdaq Composite .IXIC added 144.25 points, or 2.01 percent, to 7,305.90.

The Cboe Volatility Index .VIX, 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.

(For a graphic on 'U.S. stocks vs. bonds' click tmsnrt.rs/2CQOd1Y)

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 .SPLRCS fell 0.9 percent.

Shares of Kellogg K.N fell 8.9 percent after cutting its full-year profit forecast due to higher advertising and distribution costs.

The financial sector .SPSY rose 1.4 percent and the S&P 500 regional banks index .SPLRCBNKS 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.