(Reuters) - Dollar Tree Inc (>> Dollar Tree, Inc.) agreed to buy rival discount chain Family Dollar Stores Inc (>> Family Dollar Stores, Inc.) for $8.5 billion to fend off growing competition from Wal-Mart Stores Inc (>> Wal-Mart Stores, Inc.) and fellow discounter Dollar General Corp (>> Dollar General Corp.).

Dollar stores have struggled in a weak U.S. economy as Wal-Mart and other large retail chains chase penny-pinching consumers by offering more items priced at $1 or less.

The deal will give Dollar Tree more than 13,000 stores across the United States and Canada, vaulting the company ahead of Dollar General to become North America's biggest discount retailer, with more than $18 billion in annual sales.

While the sale is a big win for Family Dollar's largest shareholder, Carl Icahn, the activist investor responded to the offer by saying there were "a handful of potential buyers" that he believed would be a better fit.

"(We) are hopeful that one or more of them will surface," Icahn said in a statement. He had touted Dollar General as a potential buyer.

Family Dollar's shares rose to $75.53 in afternoon trading, above the cash-and-stock offer that valued the company at $74.50 per share.

Dollar Tree shares were up 3.5 percent at $56.13. Dollar General and Wal-Mart shares were slightly down.

Dollar General and Wal-Mart declined to comment.

Icahn stands to make about $200 million from the deal, a gain of about 32 percent on the price at which he bought his 9.4 percent stake in Family Dollar this year, according to Reuters calculations.

NEW SHERIFF

Dollar Tree sells a mix of consumables in suburban stores across most U.S. states, as well as discretionary items such as gifts, party goods and greeting cards. Everything has a price tag of $1 or less.

Most Family Dollar stores are in low-income neighborhoods. Its presence is biggest in Texas and the eastern United States, where it sells lower-margin consumables such as food and household products.

"This acquisition will extend our reach to lower-income customers," Dollar Tree Chief Executive Bob Sasser said.

Family Dollar, which also sells many items at more than $1, has been struggling to reverse declining sales and earnings. The company has slashed prices on 1,000 basic items, cut jobs and shut hundreds of stores.

"With a new sheriff in town, Family Dollar will be a much sharper competitor," Sterne Agee & Leach analysts wrote in a note.

Sasser said it was "too early to say" whether Dollar Tree planned to cut jobs or close stores. Most of the $300 million in annual savings expected by 2018 would come as a result of procurement and distribution, he told Reuters.

"(Family Dollar) can produce more sales per square foot in their stores than they're currently producing," said Sasser. "That can be done through expanding the better categories and contracting the lesser categories."

Family Dollar had about 34,000 full-time employees and about 24,000 part-time employees, as of Aug. 31. Dollar Tree had about 17,600 full-time and 69,800 part-time employees as of Feb. 1.

Dollar Tree offered $59.60 in cash and the rest in stock for each Family Dollar share, in a deal with an enterprise value of about $9.2 billion.

Dollar Tree said it had secured bridge financing from JP Morgan Chase Bank that, along with existing cash and bonds, would be used to finance the deal.

J.P. Morgan Securities LLC is financial adviser to Dollar Tree. Morgan Stanley & Co LLC is advising Family Dollar.

(Editing by Savio D'Souza and Don Sebastian)

By Devika Krishna Kumar and Ramkumar Iyer