A $10 billion mega-merger between two of the nation's largest drug stores is no more.

Walgreens and Rite Aid announced Thursday that they are no longer combining forces. Not entirely, at least.

Instead, Walgreens agreed to buy 2,186 Rite Aid stores for $5.2 billion. That will essentially cut Rite Aid in half, leaving it with 2,350 stores after the deal is done.

The merger agreement faced intense scrutiny from the start. It would have left the United States with just two major pharmacy chains: Walgreens and CVS (CVS). The Federal Trade Commission was scheduled to rule on the merger Thursday, and was widely expected to nix it.

The old deal was two years in the making. Initially a $17 billion deal announced in October 2015, the agreement was reworked in December 2016 and scaled back in January 2017.

As part of the revised deal, Southeastern drug chain Fred's would have purchased about 1,000 Rite Aid stores. That's no longer happening, and Fred's stock fell by 20% in premarket trading.

Michael Polzin, a spokesman for Walgreens, declined to comment on whether the looming FTC decision finally scuttled the deal. But he acknowledged that the FTC had raised concerns, and the company is confident that buying a couple thousand Rite Aid stores will pass muster with regulators.

The Rite Aid pharmacies that Walgreens plans to buy will eventually be rebranded as Walgreens stores. That won't happen for a while, though: The deal first needs to gain regulatory approval, and then Walgreens plans to buy up the Rite Aid stores over the course of six months.

Because there are so many stores in the deal, it could take two to three years for the thousands of Rite Aid stores to become Walgreens stores. So save your Wellness+ card.

Related: Store closings have tripled so far this year

Walgreens will pay Rite Aid $325 million for canceling the merger. But it expects the store purchases to save it more than $400 million over time.

The deal comes at a crucial time for Rite Aid and the retail business as a whole. Both companies also reported their quarterly financials, and they told two very different stories: Walgreen's earnings rose 5%, sales were up 2% and the company even raised its outlook for this quarter. Rite Aid meanwhile reported a loss and sales that fell by 5% last last quarter.

Shares of Rite Aid (RAD) tanked 20% in premarket trading, after falling 20% on Wednesday and 7% on Tuesday. Walgreens (WBA) rose 4%.