Stocks moved higher on Monday after energy ministers from Russia and Saudi Arabia called for an extension to an oil production cap agreement. 

The S&P 500 was up 0.45%, the Dow Jones Industrial Average added 0.37%, and the Nasdaq rose 0.37%. The Nasdaq hit an all-time intraday high Monday morning. 

Crude oil prices rallied on Monday after the surprise move from Saudi Arabia and Russia. The ministers called for the current deal among the Organization of the Petroleum Exporting Countries to be extended by nine months, far longer than what analysts had hoped. Speaking in Beijing on Monday, Saudi Arabia's energy minister, Khalid al-Falih, and Russia's Alexander Novak said they wanted the current agreement to continue holding back around 1.8 million barrels of oil from the market each day until the first quarter of 2018. 

"The two ministers agreed to do whatever it takes to achieve the desired goal of stabilizing the market and reducing commercial oil inventories to their five-year average level," the ministers said in a joint statement, "as well as to underscore the determination of oil producers to ensure market stability."

An extension to the OPEC deal will be the main point of conversation when the 13 member countries meet in Vienna on May 25. The current agreement, established last November, is set to expire at the end of June.

"There seems to be a real commitment about reducing the glut from oil powerhouses that are Saudi Arabia and Russia -- the latter being the largest oil producer in the world and the former being the largest exporter," said Fawad Razaqzada, market analyst at "Given the backing of Russia, in my view an agreement will be made. The market clearly expects that, with oil prices making a sharp comeback."

West Texas Intermediate crude was up 2.5% to $49.05 a barrel on Monday morning.

Energy stocks made big gains on Monday. Major oil producers including Exxon Mobil (XOM) - Get Report , Royal Dutch Shell (RDS.A) , Chevron (CVX) - Get Report , PetroChina (PTR) - Get Report , Total (TOT) - Get Report , BP (BP) - Get Report  and Schlumberger (SLB) - Get Report were all higher. The Energy Select Sector SPDR ETF (XLE) - Get Report increased 1.3%. 

Schlumberger is a holding in Jim Cramer's Action Alerts PLUS Charitable Trust Portfolio. Want to be alerted before Cramer buys or sells SLB? Learn more now.

But the mood on Wall Street appeared wary after a massive outbreak of cyberattacks spread across Europe. The initial attack, known as "WannaCry," paralyzed computers running Britain's hospital network, Germany's national railway and scores of other companies and government agencies around the world. 

The "WannaCry" attack was estimated to have affected more than 200,000 computers in 150 countries since its initial launch on Friday. Britain's National Cyber Security Centre warned the cyber attack could spread "significantly" as computer systems and networks come online at the start of the working week.

Cybersecurity companies were on the upswing Monday. Symantec (SYMC) - Get Report , FireEye (FEYE) - Get Report  and Palo Alto Networks (PANW) - Get Report were each higher. The PureFunds ISE Cyber Security ETF (HACK) - Get Report rose more than 3%. 

Wall Street closed mixed on Friday after Nordstrom (JWN) - Get Report and J.C. Penney (JCP) - Get Report became the latest retail names to report on a weak quarter. The Dow closed lower for its fourth straight session in a row.

Wall Street is trapped in a "momentum-less" market, Bob Byrne said over on our premium site for investors Real Money. Get his insights with a free trial subscription to Real Money.

Manufacturing activity in the New York area fell into negative territory in May, according to the Empire State manufacturing survey. The measure dropped to negative 1 this month from positive 5.2 in April. Analysts had anticipated an increase to positive 7. The headline number was in negative territory for the first time this year. New orders declined to negative 4.4 this month, the worst reading in a year. 

Homebuilder sentiment improved in May as confidence in demand remained strong. The National Association of Home Builders' housing market index rose 2 points to a reading of 70, above consensus of a flat reading of 68. The NAHB said "existing home inventory remains tight" meaning that demand for new construction should continue. 

Thermo Fisher Scientific (TMO) - Get Report was on watch Monday after agreeing to acquire Patheon (PTHN) for $35 a share. The $7.2 billion deal, which includes $2 billion of net debt, is expected to be accretive to adjusted earnings in the first full year after closing. The acquisition is expected to close by the end of the year. Patheon shares jumped more than 30%. 

Moody's (MCO) - Get Report will purchase Dutch business information providerBureau Van Dijk for about $3.3 billion in a move that will expand the ratings agency's risk, data and analytics business. The company expects the purchase to benefit top- and bottom-line results slightly in 2018 and become fully accretive by 2019. Earlier this year, Moody's acquired the structured finance data and analytics business of Frankfurt-based SCDM.

Tesla (TSLA) - Get Report declined 2% after Morgan Stanley downgraded its rating on the stock to equal weight from overweight. The firm widened its full-year operating loss for this year and next after the company released its first-quarter performance. The price target was held at $305. 

Buffalo Wild Wings (BWLD)  increased 2% Monday morning after analysts at Deutsche Bank upgraded the stock to buy from hold while raising its price target to $180 from $155. The firm still sees possible risks to sales and profits in the near-term however, but cost-cutting initiatives could lessen the impact of those potential headwinds.

Cocktails & Cramer

Join Jim Cramer on May 23 for an exclusive party at Bar San Miguel, his Brooklyn tavern. You'll get to watch a screening of Mad Money, after which Jim will arrive fresh off of the CNBC set to mingle, pose for photos and answer your investing questions. Participants will enjoy dinner, drinks, an autographed copy of Jim's book Get Rich Carefully and a one-year membership to Action Alerts PLUS, Jim's club for investors. (Current AAP members will receive one extra year of membership for free.)

When: Tuesday, May 23, 6 p.m.-9 p.m. EDT

Where: Bar San Miguel, 307 Smith St., Brooklyn, N.Y.

Cost: $375 per person

Space is very limited, so click here to reserve your ticket to this exclusive event today.

Read more stories on TheStreet: