A massive public revolt that paralyzed the grocery chain Market Basket for six weeks has ended in a stunning victory for the chain's workers.

The chain's beloved CEO, Arthur T. Demoulas, will return to the company after weeks of protests that left store shelves empty.

Hundreds of employees gathered outside the company headquarters in Tewksbury, Massachusetts, to celebrate the CEO's reinstatement Thursday morning. In the photo below, employees are shown embracing the executive.

"It's great to be back together again," Demoulas said Thursday to roars of cheers in a video of his remarks. "Words cannot express how much I miss you. Words cannot express how much I love you. Because of you, I stand here with a renewed vigor and sense of purpose."

An agreement was reached late Wednesday to reinstate Demoulas, who was ousted in June by a board controlled by his cousin, Arthur S. Demoulas. As part of the deal, Arthur T. will pay more than $1.5 billion to buy his cousin's 50.5% stake in the company.

In the weeks before the deal was reached, Market Basket's business screeched to a near halt.

Arthur T. was ousted on June 23, and the following day, employees staged a massive protest in which they promised to fight for his return.

In the ensuing weeks, thousands of workers, from store managers to delivery drivers, walked away from their jobs. Deliveries stopped arriving, store shelves eventually emptied, and registers were left unmanned.

Customers also protested. They shopped at competitors' stores and then taped their receipts to Market Baskets' store windows, letting their discontent be known, the Associated Press reports.

The company fired several employees involved in organizing the protests, and more than 160 lawmakers in Massachusetts and New Hampshire got involved by signing a petition agreeing to boycott the company.

The governors of both states also stepped into the fray and promised to help negotiations.

As the standoff drew on and new management refused to cave, some workers wondered whether their efforts were in vain.

"It’s been a long road, and over the last five weeks, there have been many times where I thought, 'Maybe we’re stupid, maybe we’re naive, maybe we can’t win,'" Tom Trainor, a worker organizer who was fired, told Boston.com. "I just wanted to go back to selling groceries and taking care of customers."

Photos: Arthur T. Demoulas is back in charge of Market Basket http://t.co/otlMjyTkL4 pic.twitter.com/TXuWQqZ1EC — Boston.com (@BostonDotCom) August 28, 2014

Market Basket employees are so passionately supportive of Arthur T. because he provides compensation and benefits that far exceed industry standards, according to Boston.com. Under his control, the chain's employees enjoy profit-sharing and bonuses.

By contrast, workers perceive his cousin, Arthur S., as more interested in increasing shareholder value than rewarding workers.

But the protests weren't only about compensation. Workers say they have fought so hard for Arthur T.'s return because he takes the time to forge friendships with his employees.

"He shook hands, he attended store openings, he was proud of what everyone accomplished instead of taking credit for himself," Pamela DeSantis White, whose father worked at Market Basket for more than 40 years, told Business Insider last month.

She said Arthur T. even attended his employees' weddings and funerals.

"Not many people can say their boss does that," White said.

Rumors circulated in the final days before the agreement was reached that Market Basket would be forced to close 61 of its 71 stores if the protests continued.

But as soon as the deal was reached, delivery trucks began rolling again and workers returned to stores.

Market Basket employees had their beloved CEO back, and they appeared ready to start picking up the pieces of a business that was nearly decimated by their protests.