Walgreens Boots Alliance is scrapping its deal to buy all of rival Rite Aid and instead will buy a smaller piece of the drugstore chain, after the original takeover effort seemed doomed by antitrust regulators.

The companies announced Thursday that they would end their original deal in which Walgreens would have bought Rite Aid for as much as $7.37 billion. Instead, Walgreens will pay $5.18 billion to buy 2,186 stores, leaving Rite Aid as a regional chain.

Although the combination of the two giant pharmacy chains had been under intense scrutiny from the Federal Trade Commission and its fate was far from certain, the decision to end the old deal sent Rite Aid shares down 23 percent in premarket Thursday. Walgreens jumped 4.4 percent.

Rite Aid, in a statement, said it received feedback from the FTC “that led the company to believe that the parties would not have obtained FTC clearance to consummate the merger.”

This is the second time Walgreens has altered its plan to buy Rite Aid stores. The first agreement announced in 2015 was for $9 a share, or $9.4 billion. A revised acquisition deal announced in January valued the deal at $6.50 to $7, or between $6.84 billion and $7.37 billion, depending on how many stores changed hands.

Under the current plan, it is no longer purchasing Rite Aid at all, but merely acquiring stores and other assets from the company. Rite Aid will receive a termination fee of $325 million in addition to the purchase price.

Walgreens had been waiting for months to see whether the FTC would try to block the planned acquisition of Rite Aid, which would have vaulted the combined company past CVS Health Corp. to become the leading drugstore chain by number of stores. In May, Walgreens moved to force a U.S. decision on the matter, which was due by July 7.

The original agreement would have been for about 3,336 stores “making this agreement about one-third smaller and more likely to pass regulatory scrutiny in our view,” Leerink analyst David Larsen said in a note to clients.

The old deal also included a plan to sell as many as 1,200 Rite Aid locations to regional chain Fred’s Inc. Fred’s fell 19 percent to $10 in early trading.

“This is a disappointing outcome,” said Michael Bloom, Fred’s chief executive officer.-

Only subscribers are eligible to post comments. Please subscribe or to participate in the conversation. Here’s why.

Use the form below to reset your password. When you've submitted your account email, we will send an email with a reset code.