By Alexandra Scaggs 

U.S. stocks rallied Tuesday, continuing a rebound from an early-October swoon and leaving the S&P 500 and the Nasdaq with gains for the month.

Fueling the bounce has been renewed confidence in the U.S. economy and corporate earnings, even as the Federal Reserve is expected to announce Wednesday it is ending the bond purchases it has been using to ease monetary policy. On Tuesday, stock prices gained with help from an unexpected jump in consumer confidence to its highest level since 2007. That encouraged investors to move back into areas that are seen as riskier, traders said, after they had fled some of those sectors during steep stock-market declines earlier this month. Small-cap stocks, energy shares and technology stocks posted the strongest gains, and safe-haven investments such as Treasurys declined.

The tech-heavy Nasdaq Composite Index led major benchmarks, gaining 78.36 points, or 1.7%, to 4564.29. The index is up 1.6% in October.

The S&P 500 added 23.42 points, or 1.2%, to 1985.05 on Tuesday; it has gained 0.6% in October. The Russell 2000 Index, a small-stock benchmark, rallied 31.98 points, or 2.9%, to 1149.45.

The Dow Jones Industrial Average rose 187.81 points, or 1.1%, to 17005.75. It remains slightly lower for the month, down 0.2%.

October initially looked like it would be a tough month for stock-market bulls, as global benchmarks fell on worries about economic growth. At stocks' latest closing lows on Oct. 15, the Dow had shed 5.3% for the month and was down 6.6% from its all-time high. The S&P 500 had a 5.6% loss and was 7.4% off its September record high. The Nasdaq had lost 6.2% and was trading 8.3% below its 2014 high.

But since then, stocks have largely recovered, as companies have posted better third-quarter results than expected, and some economic reports have been better than anticipated. The S&P 500 and Dow are now less than 2% below their all-time highs from mid-September.

"We thought the selloff was unfounded, and now people are buying into the notion that it wasn't based on any change in the fundamentals," said David Lefkowitz, equity strategist with UBS Wealth Management. "It's very good for the stock market."

Stocks that have struggled in recent weeks rallied, outpacing the broader market's rise. Two sectors that led the early-October declines rallied alongside the Russell 2000. The Dow Jones Transportation Average jumped 1.5%, reaching a record high. Energy shares were the biggest gainers in the S&P 500, advancing 2.3%. The sector has struggled over the last three months, down 13% compared with the S&P 500's 0.3% gain.

"People have woken up to the fact that maybe global growth isn't going to collapse...so the sectors that are more economically sensitive are being bought," said Mark Luschini, chief investment strategist for Janney Montgomery Scott, which helps oversee $58 billion in assets. He added that short-term investors had bet on further declines in some of those riskier sectors and traders could be unwinding those bets.

Investors are now looking ahead to a statement from the Federal Reserve, due Wednesday at the end of its two-day meeting. The central bank is expected to end its bond-buying program, but traders say they will be closely watching the outlook for short-term interest rates. The Fed is expected to raise short-term rates in 2015.

In economic news, the upbeat consumer-confidence reading outshined a surprise decline in durable-goods orders. Orders for durable goods fell 1.3% in September, marking the second consecutive month of declines, while a rise of 0.7% was expected. Stocks pared gains after the report, but only briefly.

A report on home prices in 20 U.S. cities from S&P/Case-Shiller showed a rise of 5.6% in August, while economists forecast a rise of 5.7%. A report on manufacturing in the mid-Atlantic region beat forecasts, as the Federal Reserve Bank of Richmond's manufacturing index rose to 20 in October, while a slide to 10 was expected.

A broad advance in European stocks helped set a positive tone early in the session. The Stoxx Europe 600 gained 1%. Crude-oil futures gained 0.5% to $81.42 a barrel. Gold futures edged up less than 0.1% to $1229.20 an ounce.

Demand for safe-haven U.S. government debt declined, pushing the yield on the 10-year Treasury note up to 2.284% from 2.257% on Monday.

Third-quarter earnings from companies have been better than expected in recent sessions. With 244 companies reporting, the S&P 500 is on pace to grow earnings 6% in the third quarter, according to FactSet, above the 4.5% expected before the start of reporting season.

"Even with European [economic] data deteriorating, these companies' earnings are able to keep grinding higher," said Michael Purves, chief global strategist at Weeden & Co. "That's a very important sign here."

In earnings news, Pfizer Inc. advanced 0.2% after it reported third-quarter results that beat analysts' estimates and tightened its profit and revenue outlook for the year.

DuPont Co. edged up 0.1% after it said earnings jumped 52% in its third quarter on lower expenses.

Aetna Inc. lifted its earnings outlook for the year and reported third-quarter results that beat expectations. But shares fell 2.5%. The stock is up 13% so far this year.

Twitter Inc. sank 9.8% after it said Monday it added 13 million monthly active users in the third quarter, up 4.8%. That is a slower pace than the 6.3% added in the previous quarter. The slowing user growth overshadowed Twitter's revenue, which more than doubled in the quarter and prompted an increase in full-year guidance.

Coach Inc. reported a decline in profit and sales in the latest quarter, with a slump in North American sales offsetting sales gains internationally. Results topped expectations, but shares fell 5.9%.

Write to Alexandra Scaggs at alexandra.scaggs@wsj.com

Nasdaq (NASDAQ:NDAQ)
Historical Stock Chart
From Mar 2024 to Apr 2024 Click Here for more Nasdaq Charts.
Nasdaq (NASDAQ:NDAQ)
Historical Stock Chart
From Apr 2023 to Apr 2024 Click Here for more Nasdaq Charts.