NEW YORK (AP) -- Stocks climbed Wednesday as investors clung to hope for an international deal to stem a global glut in crude oil with production cutbacks. That sent the price of oil sharply higher, as well as the stocks of major energy companies like Chevron. Tech stocks also rose, led by Microsoft and Facebook.
The gains capped a three-day rally, the longest so far in 2016, that has wiped out about half of the market's losses since the beginning of the year. The Standard & Poor's 500 index hit its lowest point of the year last Thursday, and has risen about 5 percent since then.
Priceline, Fossil, and Garmin rose after reporting robust earnings.
The Dow Jones industrial average gained 257.42 points, or 1.6 percent, to 16,453.83. The S&P 500 rose 31.24 points, or 1.7 percent, to 1,926.82. The Nasdaq composite index jumped 98.11 points, or 2.2 percent, to 4,534.06.
The price of oil recovered as investors again hoped for an international deal that will cap or cut production. Several OPEC nations are in talks about freezing production at January's levels, but that deal requires all of OPEC's members to agree, and Iran said Wednesday that it won't stop increasing its exports. Still, investors appeared to be encouraged that the countries are talking.
The price of U.S. crude jumped $1.62, or 5.6 percent, to $30.66 a barrel in New York. Brent crude, a benchmark for international oils, rose $2.32, or 7.2 percent, to $34.50 a barrel in London.
U.S. crude soared Friday on anticipation of a deal, but even with the recent gains, it's still down 17 percent this year.
Energy stocks climbed along with the price of oil. Chevron rose $3.50, or 4.1 percent, to $88.31 and Hess picked up $2.63, or 6.4 percent, to $43.47. Tech stocks made big gains, led by Microsoft, which added $1.33, or 2.6 percent, to $52.42, and Facebook, which rose $3.59, or 3.5 percent, to $105.20.
Oil and natural gas company Devon Energy missed out on those gains after saying it will eliminate 20 percent of its staff in the first quarter and slash its spending and its quarterly dividend in response to the diminished price of oil.
The stock lost 93 cents, or 4.4 percent, to $20.33. It's down 69 percent over the last year.
For almost six months, stocks have surged and dropped repeatedly as investors worry about issues like the health of China's economy, the Federal Reserve's plans on interest rates, and plunging oil prices. Sameer Samana, global quantitative strategist for Wells Fargo Investment Institute, said the ride isn't over yet.
"None of those issues have gone away," Samana said. "You'll continue to see that kind of pattern."
Samana said U.S. companies, and large stocks in particular, are doing pretty well and that investors will eventually start paying more attention to their performance. But he said it's possible that volatility in financial markets will start to affect the broader economy, cutting into consumer spending and prompting businesses to cut jobs.
While corporate earnings have been shaky, companies that surpassed analysts' expectations were rewarded on Wednesday. Online travel company Priceline climbed after its profit and revenue beat estimates. The stock gained $124.88, or 11.2 percent, to $1,235.56. Expedia rose 5 percent and TripAdvisor 3 added percent. Expedia and TripAdvisor posted strong results last week.
Personal navigation device maker Garmin rose $5.83, or 16.5 percent, to $41.06 after its fourth-quarter profit topped Wall Street estimates.
Watch and accessories maker Fossil posted strong results, and its annual profit guidance also pleased investors. The stock added $9.84, or 28.6 percent, to $44.30. Fossil was one of the worst-performing stocks in the S&P 500 last year. It lost almost two-thirds of its value as fitness trackers became more popular and the Apple Watch was launched.
Pipeline company Kinder Morgan jumped 10 percent on the rise in oil prices and from the news that Warren Buffett's Berkshire Hathaway has taken a 1.2 percent stake in the company. The stock advanced $1.56 and closed at $17.18.
U.S. factories cranked out more cars, furniture and food in January. The Federal Reserve said factory output rose 0.5 percent, the biggest increase since July. Output had fallen in four of the previous five months, and the data suggests U.S. manufacturing may be recovering after struggling last year. While the strong dollar and weak overseas growth have cut into exports and corporate profits, Americans are spending at a solid pace.
In other energy trading, wholesale gasoline rose 3.3 cents to $1 a gallon. Heating oil rose 6.1 cents, or 5.9 percent, to $1.088 a gallon. Natural gas added 3.9 cents, or 2 percent, to $1.942 per 1,000 cubic feet.
The price of gold rose $3.20 to $1,211.40 an ounce and silver inched up 4.3 cents to $15.377 an ounce. Copper added 2.5 cents to $2.076 a pound.
European stocks also rallied. Germany's DAX rose 2.7 percent and France's CAC 40 gained 3 percent. Britain's FTSE 100 picked up 2.9 percent. Asian stocks slumped, however. Japan's Nikkei 225 fell 1.4 percent as investors shrugged off data showing strong machinery orders in January. Hong Kong's Hang Seng dropped 1 percent while the Shanghai Composite rose 1.1 percent.
The yield on the 10-year Treasury note jumped to 1.82 percent from 1.78 percent. The dollar slipped to 113.77 yen from 113.88 yen. The euro slipped to $1.1139 from $1.1144.