U.S. stocks were mostly lower despite a strong performance by energy shares after OPEC members reached an agreement to cut petroleum production.

The S&P 500 Index soared at the market’s open and surpassed it’s record high, but then retreated and was down 0.27 percent to 2,198.81 at 4 p.m. in New York. The Dow Jones Industrial Average also touched a record high before fading and was essentially flat at 19,123.58. The Nasdaq Composite Index fell more than 1 percent to 5,323.68.

Earlier Tuesday, the Organization of Petroleum Exporting Countries reached an agreement to curtail oil supply by 1.2 million barrels, the first cut in eight years.

“Today, with a significant rally in crude, it’s up about 8 percent or so, leadership is going to come from energy,” said Yousef Abbasi, a global market strategist at JonesTrading Institutional Services LLC. “There is going to be a positive tail wind off of this”

Energy stocks climbed 4.82 percent as a group. Devon Energy Corp. gained 14.63 percent and Marathon Oil Corp. rose 20.8 percent, both hitting 52-week highs

“An agreement on production cuts is positive for oil stocks in the short term, but the upside to oil prices will be limited,” said Heinz-Gerd Sonnenschein, an equity strategist at Deutsche Postbank AG in Bonn, Germany. “U.S. stocks still have further to gain as Trump’s policies seem to be heading in a better direction than people expected before the election.”

Stocks have rallied in November, with all major U.S. indexes touching records, on speculation president-elect Donald Trump will increase fiscal spending to stimulate the world’s largest economy. The S&P 500 has climbed 3.4 percent, on track for its biggest monthly advance since July.

Reports on pending home sales and the Federal Reserve’s Beige Book are due later today, as well as a private release on employment. Investors are also awaiting the government payrolls data on Friday for clues on the pace of future interest-rate hikes from the Federal Reserve. The probability of a rate increase in December is at 100 percent, compared with a 68 percent chance at the start of November.

“The only things that really changed since the last Beige Book were the election, the dollar, and inflation,” said Brian Jacobsen, chief portfolio strategist at Wells Fargo Funds Management LLC. “Election uncertainty was cited as holding back auto sales, hiring, and construction. Now, that uncertainty is resolved and that excuse goes away.”