Billionaire investor Carl Icahn has sold his entire stake in Family Dollar Stores Inc (FDO), making a profit of about $200 million on the investment, according to sources familiar with the matter on Wednesday.

Dollar Tree Inc (DLTR) agreed in July to buy Family Dollar for $8.5 billion. Since then, however, the deep-discount retailer has drawn competing interest from Dollar General Corp (DG), which has bid $9.1 billion for its smaller rival.

Icahn became Family Dollar's largest shareholder in June, when he disclosed a 9.4 percent stake in the struggling retailer and pushed the company to sell itself.

At the end of July, Icahn disclosed he had reduced his position to 3.61 percent.

It was not clear when Icahn sold the remaining stake. But his decision could indicate he did not expect a tussle for Family Dollar between its two suitors to lead to a substantial increase in the deal price. His decision also reduces some activist pressure on Family Dollar.

Icahn had pushed Family Dollar to sell itself to Dollar General and was openly critical of Family Dollar Chief Executive Howard Levine, who would have retained his position after an acquisition by Dollar Tree.

In an interview with Reuters last month, Icahn said: "This is a quintessential example and a reflection of what is wrong with corporate America."

Icahn had also criticized Family Dollar's performance over the last few years. In a June 19 regulatory filing, he said the company not only underperformed its peers but also the S&P 500 index over the last 1-year and 3-year periods.

Another activist investor, Nelson Peltz's Trian Fund Management LP also owns 7.34 percent in Family Dollar, according to Thomson Reuters data.

Trian's Chief Investment Officer Edward Garden has been a Family Dollar board member since 2011, and served on a committee of four directors that oversaw Family Dollar's strategic alternatives including the Dollar Tree deal.

Family Dollar's traded around $80.22 on Wednesday, unchanged on the day. Dollar General has offered $80 per share for the company, while Dollar Tree has a deal to buy Family Dollar for $74.50 per share. 

(Reporting by Nadia Damouni; Editing by Paritosh Bansal, Meredith Mazzilli, Jeffrey Benkoe and Nick Zieminski)