(AP) -- U.S. stocks closed sharply higher Thursday, snapping a two-day losing streak.
Investors cheered strong quarterly earnings from Wal-Mart Stores, Cisco Systems and other companies. Technology stocks accounted for much of the market's gains, which helped lift the Nasdaq composite to its first record high in just over a week.
Health care companies and consumer product makers also posted solid gains. Energy and utilities stocks lagged. Oil prices declined.
The rally knocked the major stock indexes into positive territory for the month, as investors seized on the encouraging company earnings news to buy shares a day after the market suffered its worst decline in two months.
"Investors have been looking to buy on weakness and they got a little bit of it," said Erik Davidson, chief investment officer for Wells Fargo Private Bank. "The desire to buy in dips has been very, very strong and we've seen a little bit of a dip."
The Standard & Poor's 500 index rose 21.02 points, or 0.8 percent, to 2,585.64. The Dow Jones industrial average gained 187.08 points, or 0.8 percent, to 23,458.36. The Nasdaq added 87.08 points, or 1.3 percent, to 6,793.29. The Russell 2000 index of smaller-company stocks picked up 22.79 points, or 1.6 percent, to 1,486.88.
The major stock indexes were poised to rebound from the start of trading Thursday following solid gains in markets in Europe and Asia. Investors shrugged off the prior day's doldrums and welcomed latest batch of strong corporate earnings or outlooks.
Data storage company NetApp vaulted 15.9 percent as investors applauded its quarterly results and forecasts. The stock was the biggest gainer in the S&P 500 and one of the reasons technology stocks posted some of the biggest gains. Its shares rose $7.29 to $53.11.
Cisco Systems also delivered a bigger profit than analysts expected. The internet gear maker also said revenue should grow in the current quarter after two years of declines. Cisco shares climbed 5.2 percent, its biggest gain since February 2016. The stock added $1.77 to $35.88.
Wal-Mart also got a big boost, climbing 10.9 percent, its biggest gain since October 2008. In addition to posting strong third-quarter results, the retail giant raised its annual profit outlook. The stock rose $9.79 to $99.62.
A forecast for better full-year sales helped lift J.M. Smucker 9.5 percent. The food company's shares gained $10.14 to $116.65.
"We've had very good earnings from Amazon, Google, Nvidia, Tencent, just to name a few," said Tom Martin, senior portfolio manager with Globalt Investments. "Even with Wal-Mart you're seeing a very strong reaction to the positives that are going on there."
The quarterly report card from some companies failed to put traders in a buying mood.
Best Buy fell 3.6 percent after the electronics retailer's latest quarterly results and forecast for the holiday season fell short of estimates. The stock slid $2.05 to $55.25.
Apart from earnings, investors had their eye on developments in Washington, where the House voted to pass a near $1.5 trillion package overhauling corporate and personal taxes.
The focus now moves to the Senate, where lawmakers were working on a different version of a tax reform bill. Both the House and Senate versions of the legislation would slash the 35 percent corporate tax rate to 20 percent and reduce some personal taxpayers' rates.
Expectations of a big business tax cut have helped lift the market higher this year, though the Thursday afternoon House vote didn't move the market's much.
"To have a bit of positive news on tax reform is helpful, but there's still a long way to go with that," Martin said.
Traders bid up shares in Procter & Gamble after activist investor Nelson Peltz said an independent count showed he won election to the consumer products company's board. The stock added $1.02, or 1.2 percent, to $89.25.
Time soared 28.1 percent after The New York Times reported that Meredith Corp. will make another offer for the publisher. Time gained $3.55 to $16.20.
Bond prices fell. The yield on the 10-year Treasury note rose to 2.37 percent from 2.32 percent late Wednesday.
Energy prices declined. Benchmark U.S. crude slipped 19 cents to settle at $55.14 a barrel on the New York Mercantile Exchange. Brent crude, used to price international oils, slid 51 cents to $61.36 a barrel in London.
Wholesale gasoline gave up 3 cents to $1.71 a gallon. Heating oil dipped a penny to $1.90 a gallon. Natural gas declined 3 cents to $3.05 per 1,000 cubic feet.
Gold edged up 50 cents to $1,278.20 an ounce. Silver added 10 cents to $17.07 an ounce. Copper shed 1 cent to $3.05 a pound.
The dollar strengthened to 112.98 yen from 112.89 yen on Wednesday. The euro weakened to $1.1765 from $1.1794.
Major stock indexes in Europe also notched gains Thursday. Germany's DAX rose 0.5 percent, while France's CAC 40 added 0.7 percent. Britain's FTSE 100 picked up 0.2 percent.
Earlier in Asia, Japan led the region higher as its benchmark Nikkei 225 snapped a six-day losing streak and jumped 1.5 percent. South Korea's Kospi added 0.7 percent. Hong Kong's Hang Seng index gained 0.6 percent. Australia's S&P/ASX 200 rose 0.2 percent.