Copper rebounded from six-year lows and oil prices also rallied, helping push the S&P 500 energy index <.SPNY> up 3.1 percent, its biggest daily percentage jump since January, and the materials index <.SPLRCM> up 2.5 percent.

Disappointing economic data in China boosted hopes for additional stimulus from Beijing, lifting Chinese stocks. Adding to investor optimism, Greece and international creditors could wrap up a multibillion-euro bailout accord by Tuesday.

Buffett's Berkshire Hathaway (>> Berkshire Hathaway Inc.) said it would buy Precision Castparts (>> Precision Castparts Corp.) in a deal valuing the company at $32.3 billion. Precision Castparts' shares jumped 19.1 percent to $230.92, while Berkshire's Class B shares dipped 0.1 percent to $143.42.

The Dow Jones industrial average <.DJI> rose 241.79 points, or 1.39 percent, to 17,615.17, the S&P 500 <.SPX> gained 26.61 points, or 1.28 percent, to 2,104.18 and the Nasdaq Composite <.IXIC> added 58.25 points, or 1.16 percent, to 5,101.80.

The benchmark S&P 500 index registered its biggest daily percentage gain since May 8.

After the bell, shares of Google (>> Google Inc) climbed 4.8 percent after it announced it is changing its operating structure by setting up a new company called Alphabet Inc, which will include the search business and a number of other units. Stock futures rose further following the news.

During the regular session, Twitter (>> Twitter Inc) shares jumped 9.1 percent to $29.50 after CEO Jack Dorsey joined other insiders in buying more shares, while the company also clinched a multiyear partnership with the National Football League.

On Friday, the Dow closed lower for the seventh straight session after solid U.S. jobs data for July pried the door open a little wider for a Federal Reserve rate hike in September.

With U.S. interest rates near zero for almost a decade, debt has been cheap. But with the Fed widely expected to hike rates later this year, merger and acquisition activity has accelerated.

July was the seventh strongest month for global deal activity since 1980. Through July, cross-border M&A activity totaled $913.5 billion, up 23 percent from a year earlier, according to Thomson Reuters data.

"We've had a whole lot of M&A throughout the year, and that's positive because it means businesses are upbeat on the prospects for the economy," said Peter Cardillo, chief market economist at Rockwell Global Capital in New York.

In other deal news, ammonia maker CVR Partners' (>> CVR Partners LP) deal to buy Rentech Nitrogen Partners (>> Rentech Nitrogen Partners LP) for about $533 million sent Rentech soaring 28.6 percent to close at $13.25 while CVR shares were down 2.9 percent at $10.38.

On the NYSE, advancing issues outnumbered declining ones by 2,329 to 734 for a 3.17-to-1 ratio on the upside. On the Nasdaq, 1,937 issues rose and 856 fell for a 2.26-to-1 ratio favoring advancers.

The S&P 500 index posted 35 new 52-week highs and three new lows, while the Nasdaq Composite recorded 58 new highs and 85 new lows.

About 6.5 billion shares changed hands on U.S. exchanges, compared with the daily average of 7.0 billion for the month to date, according to data from BATS Global Markets.

(Additional reporting by Tanya Agrawal in Bengaluru; editing by Savio D'Souza, Nick Zieminski, Peter Galloway and G Crosse)

By Caroline Valetkevitch