The deal comes amid pressure on Family Dollar by the activist investor Carl Icahn, who urged the company last month to explore a sale of itself. But Family Dollar said in a statement that it had been exploring strategic options since the winter.

Under the terms of the deal, Dollar Tree will pay $74.50 for each share of Family Dollar. The bid is made up of $59.60 a share in cash and Dollar Tree stock worth about $14.90. Including debt, the deal values the target company at about $9.2 billion.

The bid represents a premium of nearly 23 percent to Family Dollar's closing price Friday.

Shareholders representing about 16 percent of Family Dollar's shares, including chief executive Howard Levine and the investment firm of the billionaire Nelson Peltz, have already agreed to support the deal.

Together, the two companies will have more than 13,000 stores in 48 states and in Canada, and more than $18 billion in revenue. Dollar Tree, which sells its wares for $1 or less, intends to keep Family Dollar — which has a number of low-cost price points — as a separate brand. About $300 million in annual cost savings are expected by the end of the third year after closing, which is expected by early next year.