May 9 (Reuters) - Wall Street rallied on Wednesday as surging oil prices boosted energy stocks following U.S. President Donald Trump's decision the previous day to quit a nuclear deal with Iran.

Gains were broad, with all but the utilities and telecom sectors advancing as investors who had moved to the sidelines in recent days ahead of Trump's decision returned to the market.

"It's classic 'buy on the terrible news'," said Ian Winer, director of trading at Wedbush Securities in Los Angeles. "People had gotten way too nervous about this."

Oil hit its highest level in 3-1/2 years as investors worried that Trump's decision to withdraw the United States from the international agreement aimed at preventing Iran from obtaining a nuclear bomb would increase risks of conflict in the Middle East and curtail global oil supplies.

The S&P energy index jumped 2.2 percent, bringing its gain this quarter to 12.8 percent, more than any other sectors.

"The rise in oil is helping energy sector, which is expected to be a pretty big growth sector. A lot of analysts are expecting strong earnings as oil rebounds, and that hasn't really played out so much early this year," said Shawn Cruz, senior trading specialist at TD Ameritrade in Chicago. At 2:34 pm ET, the Dow Jones Industrial Average was up 0.73 percent at 24,536.98 points, while the S&P 500 had gained 0.97 percent to 2,698.28.

The Nasdaq Composite added 0.97 percent to 7,337.66.

Worries lingered that rising oil prices would perk up inflation. The U.S. 10-year Treasury yield rose to a two-week high and above the key 3 percent level on expectations of higher interest rates.

In stock trading, Google-owner Alphabet rose 2.9 percent, providing more lift than any other stock to the S&P 500. It was followed by Facebook, rising 1.93 percent.

Walmart fell 3 percent after the retailer took a majority stake in Indian e-commerce firm Flipkart for about $16 billion.