The deal announced Tuesday will create a new company with about $83 billion in annual sales and 4,900 stores across the country.
Albertsons pharmacies will be rebranded as Rite Aid and some Rite Aids will continue to operate as stand-alone stores. Rite Aid CEO John Standley will become CEO of the new combined company.
Walgreens wanted to buy up all of Rite Aid in 2015, but federal regulators nixed that agreement on antitrust grounds. In September, the two companies announced a scaled back version for nearly 2,000 of Rite Aid's stores. That left Rite Aid with around 2,600 stores.
The move will allow Albertsons to become "a fully integrated one-stop-shop," Miller said in a statement.
Rite Aid jumped 24% in pre-market trading.
Albertsons is a privately held company and Rite Aid is public. It's not yet clear what the name of the new company will be.