Shares of U.S. oil and gas companies surged on Monday, as a jump in oil prices in the wake of attacks on Saudi Arabia's oil facilities drove a relief rally in one of the S&P 500's worst performing sectors this year.

Shares in major energy conglomerates including Exxon Mobil Corp and Chevron Corp jumped nearly 3%, while some of this year's weakest performers saw huge gains: Chesapeake Energy Corp was up 17%, Denbury Resources up 26% and California Resources up 15%.

Oil prices at one point surged nearly 20%, with Brent crude posting its biggest intraday gain since the Gulf War in 1991 after the attacks effectively shut down 5% of global crude output. 

That powered an almost 4% rise for the S&P energy index, but still left it as the second worst performing of the New York market's 11 industry sub-categories, up around 9% this year, versus a 20% gain for the S&P 500 overall .SPX .

"Obviously we're going to get a big boost today," said Randy Frederick, vice president of trading and derivatives for Charles Schwab in Austin, Texas. "But its very unclear whether or not this is going to have any long-term effect."

Analysts from heavyweight Wall Street brokerages stressed the broader uncertainty the attacks generate for the global oil market in the months ahead.

In a morning note to clients, JP Morgan estimated crude could jump by anything between $5 and $30 a barrel in the months ahead.

"The apparent sophistication of the attack in terms of both the target and its execution should re-establish or re-emphasize a geopolitical risk premium into the price of oil," they said.

Energy shares have lagged the broader market this year as China threatened to impose tariffs on U.S. crude oil imports for the first time, while a protracted trade war between the United States and China heightened the risk of a world recession.

Analysts say investors have also become wary of energy companies who have out-spent their cash flows and drilled wells without adequate returns in a boom in shale production that has made the United States the world's biggest producer.

That may make the weekend's events a relief after months of underperformance for many, but the Goldman note also highlighted a number of firms who may lose out relative to better-positioned peers.

Companies that import Saudi crude, including PBF Energy Inc, Valero Energy, Marathon Petroleum Corp and Phillips 66 would all be more exposed to the drop in supplies, while any spike in crude prices could also hurt the retail and wholesale operations of Marathon and Phillips 66.

"Inland refiners should be more protected in the near-term from any crude disruption given they source more barrels domestically," they wrote in the note.

"For the U.S. majors, we expect the most significant upside reaction to the Saudi disruption for ConocoPhillips, especially in light of YTD underperformance versus Exxon or Chevron."

(Reporting by Susan Mathew, Ambar Warrick and Sruthi Shankar in Bengaluru; editing by Patrick Graham) ((sruthi.shankar@thomsonreuters.com; within U.S. +1 646 223 8780; outside U.S. +91 80 6749 6328;))