Walgreens terminated its merger with Rite Aid, but despite leaving the deal behind, Walgreens will pay $5.175 billion in cash to buy 2,186 Rite Aid stores.

Corrections & Clarifications: Corrects an editing error to state that it was Rite Aid shares that fell 26.5% Thursday 

Walgreens abandoned its deal to acquire drugstore chain Rite Aid and will instead buy nearly half of its smaller rival’s stores for $5.1 billion after U.S. regulators raised antitrust concerns about the original plan.

The long-suffering deal’s implosion preserves the three largest drugstore chains as independent entities, but the new agreement will still make Walgreens Boots Alliance, its official name,  the nation’s largest by number of locations, edging archrival CVS Health.

Consumer advocates gently welcomed the development, saying the original accord would have given Walgreens too much pricing power but cautioning that the new deal may still require oversight scrutiny.

“This merger would have led to higher prices,” former FTC policy director David Balto said. “It’s important to preserve three national competitors. That’s in essence what the FTC was saying.”

Walgreens said Thursday that it would buy 2,186 Rite Aid stores, three distribution centers and inventory. Rite Aid investors reacted badly to the news, causing its shares to plunge 26.5% Thursday.

To be sure, the new deal must still pass regulatory muster, which could be stiff if officials suspect that Walgreens would have too much pricing power or bargaining leverage.

With the new agreement, Walgreens would have more than 10,200 U.S. stores, giving the chain opportunities for cost cuts and greater leverage in negotiation with landlords, health-care companies and vendors. CVS has more than 9,600 stores.

Rite Aid, which currently has about 4,600 locations, is selling stores primarily located in the Northeast, Mid-Atlantic and southeastern U.S. 

As a result of the original deal’s cancellation, Walgreens owes Rite Aid a $325 million breakup fee — a customary provision in major merger agreements to compensate the targeted company if a deal collapses.

The move also means that Rite Aid’s previous deal to sell certain stores to drugstore chain Fred’s, in an effort to assuage regulators, is off.

Walgreens CEO Stefano Pessina said the new deal would allow the company to make its stores more efficient, with a…