Dollar Tree has agreed to pay roughly $8.5 billion to acquire rival Family Dollar Stores, a merger that will join two of the largest discount-focused retail chains at a time when many consumers are still struggling to recover from the Great Recession.

Under the terms of the deal, which was approved by both companies’ boards of directors, Dollar Tree DLTR has agreed to pay $74.50 per share in a cash and stock deal to buy Family Dollar. The valuation of that offer is a roughly 23% premium over Family Dollar’s FDO closing price on Friday. Dollar Tree, which expects the deal to close by early next year, will pay $59.60 in cash and the rest in shares. At closing, Family Dollar shareholders will own some shares in the merged company.

The combined companies will operate more than 13,000 stores across 48 states and five Canadian provinces, with annual sales exceeding $18 billion. That would put a merged Dollar Tree-Family Dollar slightly above rival Dollar General DG , which reported about $17.5 billion in sales in its latest fiscal year.

All three chains target lower-income consumers, though Dollar Tree sells everything in its stores for $1 or less, while Family Dollar has multiple price points to court value-conscious shoppers.

The planned takeover of Family Dollar comes after activist investor Carl Icahn called on the company to put itself up for sale “immediately.” Icahn, who took a 9.4% stake in the retailer in June, said the company consistently underperformed its peers and faced more intense competition. Family Dollar’s latest fiscal quarterly results were mixed, as the company reported a 33% drop in profit on restructuring charges and fewer customer transactions.

Icahn, in a prepared statement, said the Family Dollar acquisition highlighted that activism was “alive and well” but also indicated other buyers could be lurking.

“While we continue to believe there are a handful of potential buyers who could realize greater synergies through a combination with Family Dollar and are hopeful that one or more of them will surface as a result of today’s announcement, we are extremely pleased with Dollar Tree’s intention to acquire Family Dollar,” Icahn said.

Dollar Tree intends to finance the deal through a combination of existing cash on hand, bank debt and bonds. The company sees an estimated $300 million of annual run-rate synergies to be fully realized by the end of the third year after the deal closes. The deal is expected to add to Dollar Tree’s earnings in the first year, excluding one-time costs to achieve those synergies. Family Dollar is being acquired as the company is in the process of closing 370 underperforming stores and also cutting corporate overhead costs.