Albertsons Cos., the profit-challenged, debt-laden company that owns Acme, Safeway, Jewel-Osco, and other grocery chains, is buying Camp Hill, Pa.-based Rite Aid Corp., the third-largest U.S. drugstore chain, whose share price tumbled after last year's failed merger and partial sale to rival Walgreens.

The deal, which values Rite Aid equity at nearly $3 billion, would make Albertsons a public company, using Rite Aid's New York Stock Exchange listing. If the deal is approved by regulators and Rite Aid shareholders, the combined company — a "Food, Health, and Wellness Leader," Rite Aid says — will operate 4,900 stores, including more than 2,000 stand-alone Rite Aids. Sales would total $83 billion a year, with profits (before interest, taxes, and amortization) of around $3.7 billion.

While officials of both companies said they are taking steps to reach shoppers online in the face of stiff competition, they also suggested that store sites could be more valuable than grocery or drug sales. Together they will own real estate appraised at more than $11 billion, Albertsons chief financial officer Bob Dimond told investors in a conference call. That includes "a significant number of trophy locations, with opportunities for development."

The move is the latest convulsion rocking the retail pharmacy business, as more drug-using Americans buy their medicines direct, through online suppliers including Amazon.

Chain pharmacies, including Rite Aid, grew by underpricing the independent pharmacies that were once a fixture on neighborhood Main Streets. But the big chains have also struggled to stay profitable, even after adding groceries, toys, and other consumer goods in stores.

Albertsons expects to shave about $375 million a year from the costs of Rite Aid's suburban Harrisburg offices and other operations, or about 5 percent of Rite Aid yearly operating expenses. Albertsons also says it will boost profits by squeezing suppliers. Albertsons plans to add the Rite Aid name to grocery drug counters. Rite Aid chairman and chief executive John Standley will lead the combined company as CEO. Albertsons chief Bob Miller will become the board chair.

Albertsons, which had planned, then canceled, a public stock offering during the period 2015 — 2017, offered Rite Aid owners either a share of its stock and $1.83 in cash, or slightly more than a single share, for every 10 shares of Rite Aid. Shares of Rite Aid closed Tuesday at $2.20, up $0.07 or 3.29 percent, though it was below the company's price last winter of around $6 a share. Shareholders of Boise, Idaho-based Albertsons will own more than 70 percent of the combined company. The companies say they will keep headquarters in both Boise and Camp Hill.

The merger is a "muddled and mediocre exit for both" Albertsons and Rite Aid, wrote analyst John Ransom, in a note to clients of brokerage Raymond James & Associates. "But, hey, it's getting late at the merger party and most of the dance partners have gone home," he added, citing recent deals by Rite Aid rivals CVS and Walgreens.

Acme was the dominant grocery chain in the Philadelphia area in the late 20th century but has lost market share to ShopRite, Wegmans, and other chains that have built large stores across the region.

Rite Aid, the third-largest U.S. drugstore chain, tried to combine with Illinois-based Walgreens last summer, but the deal collapsed amid concerns that the U.S. Justice Department would object to putting too many stores under one corporate management.

Walgreens, instead, agreed to buy up to 2,000 of Rite Aid's nearly 5,000 stores, and has since been in reported merger talks with AmerisourceBergen, the Chesterbrook-based pharmacy-distribution company whose largest owner and client is Walgreens. Rival CVS plans to buy health insurer Aetna, a Connecticut-based company with a major employment center in Montgomery County, as another means of ensuring it controls a base of drug orders.

The merger will make it easier for Albertsons investors to recover some of their cash by selling shares on the stock market, after years of financing often-unprofitable grocery-chain mergers and burdening the company with acquisition debt.

Albertsons is owned by the Cerberus Capital Management global buyout group, which is headed by John Snow, former Treasury secretary under President George W. Bush, and Dan Quayle, former vice president under President George H.W. Bush; Philadelphia-based Lubert-Adler Partners, which is co-owned by former Valley Forge Casino owner Ira Lubert and real estate specialist Dean Adler; Kimco Realty Corp., whose malls include Suburban Square in Ardmore; and the Schottenstein family of Ohio, which has an ownership interest in American Eagle Outfitters, Cold Stone Creamery ice cream parlor, and other retail brands. Lubert-Adler invests for clients including the Pennsylvania state workers' (SERS) and public school (PSERS) pension systems.