(Reuters) - Wall Street rallied sharply on Monday, juiced by a jump in Apple shares and gains from energy stocks that were backed by stronger oil prices.

Apple AAPL.O shares finished up 3.7 percent after Warren Buffett's Berkshire Hathaway BRKa.N reported a stake worth about $1 billion in the iPhone maker. The stock, which had lost about one-fifth of its value in the past month, gave the biggest boost to the three indexes.

The S&P energy sector .SPNY gained 1.6 percent as oil prices hit six-month highs. Crude prices were supported by worries about global supply outages and as long-time bear Goldman Sachs sounded more positive on the market.

Oil prices have recovered some ground after touching 12-year lows earlier in 2016, with volatility in oil causing jitters in other markets.

“With oil prices being back up into that $40 range, some of the downside that was associated with the energy market ... is more subdued at these current prices, or at least held at bay, and the ripple effects from that are also held at bay,” said Jason Pride, director of investment strategy at Glenmede Investment and Wealth Management in Philadelphia.

The Dow Jones industrial average .DJI rose 175.39 points, or 1 percent, to 17,710.71, the S&P 500 .SPX gained 20.05 points, or 0.98 percent, to 2,066.66 and the Nasdaq Composite .IXIC added 57.78 points, or 1.22 percent, to 4,775.46.

All 10 major S&P 500 sectors finished higher, led by materials and energy.

Slideshow ( 2 images )

Last week, the Dow and S&P 500 fell for a third straight week, while the Nasdaq’s losing streak hit four weeks.

“Oil is the catalyst, but the move today wouldn’t have been this big if stocks had not been this weak lately,” said Jim Paulsen, chief investment strategist at Wells Capital Management in Minneapolis.

Gloomy quarterly reports from retailers had clouded the market last week. The retail sector is in focus again, with Wal-Mart WMT.N, Home Depot HD.N and Target TGT.N set to report results this week.

The S&P 500 is up just over 1 percent this year. While the benchmark index has risen about 14 percent since February lows, the rally fizzled out in the last few weeks amid mixed corporate earnings and economic data.

On Monday, Anacor Pharmaceuticals ANAC.O soared 57.2 percent to $100.67 after Pfizer PFE.N said it would buy the drugmaker in a deal valued at $5.2 billion. Anacor gave one of the biggest boosts to the Nasdaq Biotechnology index .NBI, which gained 3 percent.

Tribune Publishing TPUB.N climbed 22.8 percent to $14.08 after Gannett GCI.N raised its buyout offer to $15 per share. Gannett closed up 2.2 percent at $15.98.

About 6.5 billion shares changed hands on U.S. exchanges, below the 7.2 billion daily average for the past 20 trading days, according to Thomson Reuters data.

Advancing issues outnumbered declining ones on the NYSE by 2,318 to 699, for a 3.32-to-1 ratio on the upside; on the Nasdaq, 1,990 issues rose and 844 fell for a 2.36-to-1 ratio favoring advancers.

The S&P 500 posted 21 new 52-week highs and 3 new lows; the Nasdaq recorded 42 new highs and 66 new lows.