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

Gains were broad and volume was high, 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, referring to the wider market’s rally. “People had gotten way too nervous about this.”

Trump’s decision for the United States pull out of the international agreement aimed at preventing Iran from obtaining a nuclear weapon was good news for investors betting on a rise in oil prices. Crude hit its highest level in 3-1/2 years as investors bet the U.S. withdrawal would increase risks of conflict in the Middle East and curtail global oil supplies.

The S&P energy index .SPNY jumped 2.03 percent, bringing its gain this quarter to 12.6 percent, more than any other sector.

“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.

The Dow Jones Industrial Average .DJI rose 0.75 percent to end at 24,542.54 points, while the S&P 500 .SPX gained 0.97 percent to 2,697.79.

Traders work on the floor of the New York Stock Exchange (NYSE) in New York, U.S., May 3, 2018. REUTERS/Brendan McDermid

The Nasdaq Composite .IXIC added 1 percent to finish the session at 7,339.91.

The Cboe Volatility Index .VIX, the most widely followed barometer of expected near-term volatility for the S&P 500, closed down 1.29 points at 13.42, its lowest close since Jan. 26.

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

With March-quarter reports mostly wrapped up, S&P 500 earnings per share appear to have surged by 25.9 percent, helped by deep corporate tax cuts introduced this year, according to Thomson Reuters I/B/E/S.

In stock trading, Google-owner Alphabet Inc GOOGL.O rose 2.87 percent, providing more lift than any other stock to the S&P 500. It was followed by Facebook Inc FB.O, which rose 2.09 percent.

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

Walt Disney DIS.N dipped 1.79 percent despite reporting a quarterly profit above Wall Street estimates.

Advancing issues outnumbered declining ones on the NYSE by a 1.71-to-1 ratio; on Nasdaq, a 1.65-to-1 ratio favored advancers.

The S&P 500 posted 40 new 52-week highs and 11 new lows; the Nasdaq Composite recorded 168 new highs and 52 new lows.

Volume on U.S. exchanges was 7.1 billion shares, compared with the 6.6 billion-share average over the last 20 trading days.