Image copyright AP Image caption Workers at the Market Basket stores celebrated on Thursday after hearing their beloved boss would be back

The US supermarket chain Market Basket has agreed to sell to a majority stake to former boss Arthur T Demoulas, ending a months-long dispute.

In announcing his purchase, Mr Demoulas told workers, who had gone on strike in July to protest against his firing, "You are simply the best".

The 70-plus stores belonging to the chain are mostly located in the northeastern United States.

It was estimated the company was losing $70m (£42m) a day during the strike.

Late on Wednesday, Mr Demoulas announced that he had reached an agreement to purchase the 50.5% of the company he did not control from a rival faction controlled by his cousin, Arthur S Demoulas, for $1.5bn.

"Words cannot express how much I appreciate each and every one of you," Mr Demoulas said while addressing workers outside the company's Massachusetts headquarters on Thursday morning.

The company employs roughly 25,000 people in the area.

Long-running dispute

The saga - which had shades of a soap opera - began in June, when Mr Demoulas was ousted as chief executive of the company by a rival faction of his family, which controlled 50.5% of the firm.

The dispute was said to have been over a series of investments Mr Demoulas had authorised, which led to large losses and smaller payouts for Market Basket's shareholders.

Image copyright AP Image caption Workers and shoppers went on strike in July to protest the firing of Mr Demoulas after a family dispute

However, the dispute simmered for a month until the new management fired eight workers who had protested against Mr Demoulas's demise in July.

That is when a campaign led by Market Basket workers and customers to "Save Market Basket" began to gather steam.

Workers went on strike, truck drivers refused to deliver fresh produce and meat, and shoppers boycotted stores, leading to empty shelves and the near-collapse of the firm.

Efforts on social media also paid off, with an anonymously-run Facebook page to save the firm gathering over 90,000 likes and the hashtag, #MarketBasket, trending often on Twitter.

Image copyright Twitter Image caption The reaction on social media to news that a deal had been reached was mostly positive

This brought national and international attention to the plight of the workers, stunning many in the industry both because the workers were not unionised and because they were campaigning for an almost-unheard of thing: the reinstatement of their boss.

Although negotiations between Mr Demoulas and his cousin, Arthur S Demoulas, continued through July, tensions were further agitated when Market Basket's new co-chief executives announced a job fair in early August to hire replacement workers.

'In awe'

Now, those workers are breathing a sigh of relief.

Many tweeted pictures of newly-stocked shelves at several stores where meat counters and fresh produce areas had been empty for the past few weeks.

The question now is whether the chain, which has been essentially not in operation for two months, can recover from the essential collapse of its operations.

Image copyright Twitter / Market Basket Image caption Market Basket stores had been losing an estimated $70m in total a day as the protests wore on

Boycotting customers said they would return to shop at the store immediately, as the chain is known for its lower-than-average prices.

"See you at 7 AM tomorrow to buy anything on the shelves!!!! I don't even have a dog but I'll buy dog food if needed!!" wrote one.

Mr Demoulas, in finishing his address to workers before going to inspect several processing facilities, echoed the sentiments of many participants and observers when he said:

"I am in awe of what you have all accomplished."