By Paul Ziobro and Brent Kendall

Walgreens Boots Alliance Inc. and Rite-Aid Corp. moved a step closer to consummating a $9.4 billion merger that would leave the U.S. dominated by two retail pharmacy chains.

Under pressure from antitrust regulators, the merger partners said Tuesday they agreed to sell 865 Rite-Aid locations, leaving the proposed combination with just under 12,000 stores.

The buyer? A regional chain called Fred's Inc., which had just $5.7 million in cash and has been losing money and closing stores.

Fred's has secured $1.65 billion in borrowings to fund the all-cash, $950 million purchase plus ongoing operating costs. It has pledged nearly all its assets as collateral for the loans, including prescription files, real estate and furnishings, according to a regulatory filing. Bank of America Merrill Lynch, which advised Walgreens on the transaction, is also one of the banks leading the financing package for Fred's.

The transaction would more than double the company's size. Fred's had 650 stores as of Oct. 29 -- about half had pharmacies -- and had a market cap of about $400 million before the deal was announced.

Fred's shares surge 78% to $19.80 in Tuesday afternoon trading.

Analysts at Leerlink Partners said the company was getting a good price for the stores it is purchasing, noting Fred's is paying about seven times earnings before interest taxes and depreciation. Leerlink estimated the stores average about $5.5 million inannual sales apiece.

The transaction would give the Memphis-based company a broader reach but it would still be dwarfed by the Walgreens-Rite Aid as well as CVS Health Inc., which has 9,600 pharmacies. Fred's is also up against giants like Wal-Mart Stores Inc. and Kroger Co., which operate pharmacies in most of their locations.

Walgreens and Rite Aid have been in discussions to divest hundreds of stores for much of the past year after regulators at the Federal Trade Commission raised concerns about the combination. The companies didn't disclose which locations will be sold to Fred's.

The FTC hasn't made a final decision on whether to approve the merger with divestitures, and talks between the two sides continue, according to people familiar with the matter. An FTC spokeswoman didn't immediately respond to a request for comment.

If the commission does allow the deal to proceed, it will have a lot riding on whether Fred's successfully replaces the competition previously provided by Rite Aid. The FTC has given extra scrutiny to divestiture buyers since a high-profile settlement last year quickly went sour.

In that matter, the FTC allowed the merger of supermarket operators Albertsons and Safeway Inc. on the condition that they sell 168 stores, mostly to a small grocery chain, Haggen Holdings LLC. Haggen was supposed to use the new stores to preserve competition in several Western states.

Instead Haggen struggled with the large expansion from the outset and filed for bankruptcy protection in a matter of months. Albertsons eventually bought back some of the stores the government had required it to sell.

The Rite Aid purchase is a bold move by Fred's reshaped management team, which is now being led by former executives from Walgreens and CVS. Mike Bloom, a former executive at CVS and Family Dollar Stores Inc., took over as chief executive of Fred's in August. He had spent two years as operating chief, helping the discount retailer shift its focus to its pharmacy business. Fred's finance chief, Rick Hans, meanwhile, spent nearly three decades at Walgreens in senior finance roles.

Mr. Bloom said the company has been working for several months with Rite Aid on integration plans. Fred's will continue to operate the acquired stores under the Rite Aid brand during a 24-month transition.

For the first nine months of the year, Fred's reported a net loss of $44.1 million and sales that were flat from a year earlier at $1.6 billion. The company booked $38 million in charges in the latest quarter for inventory write-downs as well as costs tied to the closing of 40 stores next year.

Fred's said the Rite Aid deal would make it the third largest retail pharmacy chain in the U.S. and give it a wider footprint than its current base in the Southeast.

Scale is increasingly important in the drugstore business, said Adam Fein of Pembroke Consulting, who tracks drug distribution, since it can help companies negotiate more effectively with wholesalers, insurance companies and to get access to specialty drugs. He said Fred's could now be a logical buyer for a number of smaller independent pharmacies and regional chains looking to sell.

"The pharmacy industry is going through a massive consolidation endgame, " Mr. Fein said. "You have to get big, get focused or get out."

Write to Paul Ziobro at Paul.Ziobro@wsj.com and Brent Kendall at brent.kendall@wsj.com

(END) Dow Jones Newswires

December 20, 2016 15:41 ET (20:41 GMT)

Copyright (c) 2016 Dow Jones & Company, Inc.