After the intervention of two governors and an enormous public outcry, the chaos that has paralyzed the Market Basket supermarket chain ended Wednesday night with a deal between the two warring factions of the Demoulas family, the company said in a statement.

The deal approved by the chain’s board essentially meets the sole demand of the workers who have been staging huge public rallies for six weeks: that Arthur T. Demoulas, who was president until June, be reinstated to lead the company.

His cousin, Arthur S. Demoulas, and his allies agreed to sell their 50.5 percent stake in the company to Arthur T. Demoulas and his allies, who own 49.5 percent, according to the statement.

The price was more than $1.6 billion, which puts the value of the chain at about $3.2 billion, according to a person with knowledge of the agreement, who was not authorized to speak about the terms of the transaction. That valuation may seem high given that the business has ground to a halt, but it reflects optimism that the employees can rebuild it.