The all-cash transaction involves Rite Aid locations in the eastern and western United States, and would move Fred’s to the housewares retailing forefront. Along with its pharmacy products and services, Walgreens, Rite Aid and Fred’s offer housewares such as small electrics, personal-care electrics and home environment products.

The Fred’s deal is schedules to take place several months after Walgreens’ acquisition of Rite Aid closes. The transaction currently is awaiting approval from the Federal Trade Commission, and Walgreens and Rite Aid are working to close their deal in early 2017. The agreement with Fred’s is Walgreens’ response to FTC concerns about the Rite Aid acquisition, according to a Walgreens statement.

The transaction will position Fred’s as the third largest drug-store chain in the United States, according to a Fred’s statement.

“This will be a transformative event for Fred’s Pharmacy that will accelerate our health-care growth strategy through our acquisition of 865 new stores located in highly attractive markets,” said Michael Bloom, Fred’s CEO.

Rite Aid currently operates nearly 4,600 stores in 31 states. If FTC requires the divestiture of more than the 865 stores, the purchase agreement requires Fred’s to acquire the additional stores. Fred’s will operate the stores under the Rite Aid banner for a transition period of undetermined length, Walgreens said.

The proposed acquisition of Rite Aid by Walgreens was announced in October 2015. “With this agreement, we are moving ahead with important work necessary to obtain approval of our acquisition of Rite Aid,” said Stefano Pessina, executive vice chairman and CEO of Walgreens.