The Market Basket saga ended in triumph for forced-out former CEO Arthur T. Demoulas and his headstrong supporters, as the beloved grocery titan reached a deal worth more than $1.5 billion with his rival relatives last night that will see him immediately assume control of the beloved 71-store chain his family founded.

“The shareholders and the Company would like to thank Market Basket customers and partners for their strong support through the years,” Arthur T. Demoulas announced in a statement after the deal was reached. “Our shared goal is to return Market Basket to the supermarket that its customers have come to rely on.”

The chain, worth $4 billion before Arthur T.’s June 18 firing touched off a customer boycott, looked to be dying on the vine as it racked up millions in losses and shelves were left empty due to a halted supply chain.

Arthur T. supporters, including several managers who were with the company for decades and fired after his ouster, expressed confidence the business can quickly regain its footing.

“I’m thrilled, this is epic,” said Tom Trainor, a district supervisor who oversaw 37 Market Baskets in Massachusetts. “This has been an emotional roller coaster, and we have a big task ahead of us. And we’re up for the task, and we know that we’re going to prevail. We’re going to get that company back up to where it should be.”

The deal will see Arthur T. Demoulas purchase the 50.5 percent of Market Basket owned by a group of shareholders helmed by cousin Arthur S. Demoulas, his bitter rival dating back decades. Their feud led to a nasty court fight over the transfer of stocks from Arthur S.’s side of the family.

The company said Arthur T. Demoulas is returning with “day-to-day operational authority” and that he and his management team will take charge during an interim period while the transaction is completed. Co-CEOs Jim Gooch and Felicia Thornton — who were hired by Arthur S. and company after Arthur T.’s firing — will remain in place pending a closing, which is expected to occur in the next several months.

Interim control was an issue flagged by Gov. Deval Patrick after he met with the stalemated parties last Sunday, and one he indicated was satisfactorily resolved in a joint statement with New Hampshire Gov. Maggie Hassan.

“Market Basket is a major employer in Massachusetts and New Hampshire, and an important local resource for the communities the company serves,” the statement said. “We are delighted that the parties have reached agreement on terms of sale and resolution of operating authority, so that employees can return to work and customers will once again be able to rely on these stores to meet their needs.”

Market Basket board chairman Keith O. Cowan credited Patrick and Hassan for working “tirelessly and creatively to help shareholders find solutions that brought them together to reach agreement.”

The company’s board was ensnared in long — and at-times frustrating and confusing — deliberations for two weeks, with at least six scheduled board meetings coming and going as shareholders chewed over Arthur T.’s offer.

The board had a range of alternative plans drawn up in the event the sale did not go through that would have closed any number of Market Basket stores, including one plan that would close 61 of the chain’s 71 locations and lay off workers. Thousands of part-timers had already had their hours cut to zero in response to plummeting sales.

Steve Paulenka, a 40-year employee under Arthur T., said supporters will tap into the same resolve that kept them from shopping at Market Basket in protest and picketing in front of company headquarters despite threats of termination.

“Every character trait, every ounce of loyalty that has caused all these people to leave are the same things that are going to bring them back,” Paulenka said. “No question in my mind.”