Walgreens Boots Alliance Inc. agreed to acquire Rite Aid Corp. for about $9.4 billion in cash in a transaction to further expand the company’s role in the distribution of medications in the U.S.

The Rite Aid deal would combine the second- and third-largest drugstore chains in the U.S., with a total of about 12,800 locations, helping Walgreens vault past market leader CVS Health Corp. The acquisition will add to Walgreens’ earnings beginning a full year after completion and will produce more than $1 billion in savings from cost overlaps, the companies said in a statement. Including debt, the deal is valued at $17.2 billion, they said.

Walgreens will revamp Rite Aid’s stores to focus on health, wellness and beauty, just as it has been remaking its own stores since the Alliance Boots deal, the company said. Rite Aid’s stores are older and less modern, though the company had already been working to revitalize them, said Jonathan Palmer, an analyst at Bloomberg Intelligence. Rite Aid will continue to operate under its own brand at first, though eventually the plan is to integrate the two chains.

Walgreens stores reaped an average $2.4 million in revenue in the three months that ended in August, compared with $1.5 million for Rite Aid.

Speculation that Walgreens would pursue Rite Aid rose to a crescendo in March after billionaire Stefano Pessina, who took the reins as chief executive officer last January after becoming Walgreens’ largest shareholder when it combined operations with his Alliance Boots chain in the U.K. and Europe.
In addition to expanding its drugstore locations, the Rite Aid deal gives Walgreens its first foray into the business of managing drug benefits for insurers and employers, an area where rival CVS is a leader. Rite Aid entered that business by acquiring Envision Pharmaceutical Services Inc. for about $2 billion this year.

Pharmacy Benefits

If Walgreens aims to get bigger in drug-benefit management, it could use EnvisionRX to acquire other small competitors to build that business, said Ross Muken, an analyst at Evercore ISI who advises holding the shares.

Shares of drug distributor McKesson Corp. dropped less than 1 percent, as did AmerisourceBergen Corp., Walgreens’ distribution partner for medications. Rite Aid represents about $18 billion of McKesson’s revenue, according to Evercore ISI. Walgreens hasn’t made a decision on what to do with McKesson’s Rite Aid contract, Pessina said Wednesday on a conference call.

While Pessina had made clear his appetite for deals, he had been cagey about what kind of acquisition he might pursue. He has said only that the company wanted to participate in what he saw as the inevitable consolidation of the long distribution chain that delivers drugs from manufacturers to patients in the U.S.