NEW YORK — Oreo cookie maker Mondelez says it has ended discussions to buy The Hershey Co, a combination that would have created a global powerhouse selling some of the world’s best known chocolates and snacks.

Hershey had said in June that it rejected a preliminary takeover bid from Mondelez International Inc. valued at roughly $22.3 billion, according to FactSet. It said at the time that the offer provided “no basis for further discussion.”

A representative for Hershey said the company had no comment beyond acknowledging that it had been in talks with Mondelez and that they had fallen through. A deal would have been subject to the Hershey Trust, a controlling shareholder.

Hershey shares slid 11 percent in after-hours trading, to $99.25. Mondelez shares added 3.4 percent, to $44.50, in extended trading.

In a statement, Mondelez CEO Irene Rosenfeld said the company decided “there is no actionable path forward toward an agreement” following additional discussions.

Mondelez, based in Deerfield, Illinois, makes Nabisco cookies, Cadbury chocolate and Trident gum. The company was created after a split from Kraft Foods, which has since gone on to combine with ketchup maker Heinz to create the Kraft Heinz Co.

Back in June, The Wall Street Journal had reported that Mondelez told Hershey it would take the chocolate maker’s name and move its global headquarters to Hershey, Pennsylvania as part of the deal. The acquisition would have made the combined company the candy industry’s largest player, according to Euromonitor International, passing the current No. 1, Mars Inc.

The deal was seen as complementary in part because Mondelez gets most of its revenue from overseas, while Hershey gets most of its revenue from North America.

The offer to buy Hershey came as the charitable trust that controls the company has been in turmoil. In July, the trust said a board member was resigning. Later, Pennsylvania’s attorney general said it reached an agreement with the trust that involved five board members leaving, and limiting compensation. The agreement came from an investigation into the trust’s compliance with a 2013 agreement.