The shareholders of Market Basket have agreed to a deal that will see former CEO Arthur T. Demoulas and his family take complete ownership of the grocery chain.

In a statement released on behalf of Arthur T. and the company, a spokesperson confirmed the deal. The statement, in part, announced Arthur T. would return to running the company immediately:

Advertisement - Continue Reading Below

Effective immediately, Arthur T. Demoulas is returning to Market Basket with day-to-day operational authority of the company.

(Read the full statement at the end of this article.)

Arthur T. and his family, who own 49.5 percent of the company, will reportedly pay more than $1.5 billion for the 50.5 percent owned by rival family members, including Arthur S. Demoulas. That puts the full valuation at about $3 billion, in line with expert estimates of the company’s value prior to the summer’s events. The Boston Globe has reported that more than $500 million of that figure will come in the form of financing from a private equity firm.

The agreement was arrived at Wednesday after weeks of negotiations that appeared to be nearing their end in the last several days. Arthur T. announced his and his family’s bid to buy the chain in late July, a month after he was fired by the company’s board of directors. The deal became official at a Wednesday night board meeting that began at 9:30 p.m.

The deal spells the end of the summer’s standoff over the chain’s future. It also serves as the latest, if not final, bookend in the decades-old rivalry between the two sides of the Demoulas family.

Governors Deval Patrick and Maggie Hassan, of Massachusetts and New Hampshire respectively, urged the two sides to reach a deal throughout the month of August. Following the agreement, they released the following statement:

Market Basket is a major employer in Massachusetts and New Hampshire, and an important local resource for the communities the company serves. 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.

In a separate statement, Market Basket board chairman Keith Cowan thanked Patrick and Hassan for their assistance, saying their “commitment and engagement made a significant difference.”

According to a source, Arthur T. and his management team will have authority over the company’s operations while working in consultant roles until the sale’s closing. That period is expected to last months. The company’s co-CEOs, Felicia Thornton and James Gooch, who replaced Arthur T. in June, will remain in place through the closing period as Arthur T.’s team works to stabilize the chain.

The chain is indeed in need of stabilizing, as business has been decimated for nearly six weeks. While the Demoulases duelled at the company’s highest level, they did so against a backdrop of employee protests and a customer boycott aimed at forcing the issue.

The protest movement was spawned by the June 23 firing of Arthur T. as Market Basket CEO by a board that sided with Arthur S. Employees, from upper management down to grocery clerks, without union support, took action on Arthur T.’s behalf beginning the day after he was fired, with a rally in which they promised to fight for his reinstatement.

The organized effort to “shut this company down,” as workers put it, began a few weeks later when office and warehouse employees walked off the job, stunting deliveries to stores and throwing business operations into chaos. Hundreds left their positions, spurning multiple directives to return to work from Arthur T.’s replacements, co-CEOs Thornton and Gooch.

Tom Trainor, one of the organizers of the worker protest movement who was fired in July from a leadership position, told Boston.com Wednesday night that while protesters remained committed throughout the summer, he was never sure the action would result in workers’ favor.

“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,’” he said. “I just wanted to go back to selling groceries and taking care of customers.”

Customers joined workers in the movement by boycotting, a move encouraged by employees at stores. Business at Market Basket quickly fell off by more than 90 percent at some stores. In the weeks that followed, some vendors cut ties due to the effects of the dispute.

As a result of all that, Arthur T. and his workers return to a company that will need to spring fast to work to restock stores and recover.

John Sevastis, the manager of one of the company’s Fitchburg stores, told Boston.com nearly two weeks ago, in anticipation of the urgency workers will feel to rebuild the company: “When this ends, the celebration will last about five minutes.”

One vendor, Boston Sword & Tuna, which cut off business with the chain in August due to erratic payments during the summer’s events, said it was eager to get back to working with the chain. CEO Tim Malley told Boston.com the company would do “whatever it takes” to help Market Basket get back on its feet, and suggested it could provide direct-to-store deliveries in the coming days.

According to a source, recently retired Market Basket workers have also been reaching out to Arthur T. over the course of the ordeal, offering to help in the stabilization effort in the event a deal was completed.

Arthur T. has long held the support of employees, whose compensation and especially benefits are considered generous by industry standards, and customers, who appreciate Market Basket’s low prices.

Employees supportive of Arthur T. have said Arthur S. was more interested in increasing pay-outs to shareholders, a notion they saw as a threat to their compensation and the company’s culture. The idea appears to be supported by board meeting transcripts published by The Boston Globe earlier this month. Boston.com also reported this summer that Arthur S. has at least considered selling a controlling stake in the company for several years. (With that in mind, it’s probably not right to say, as some likely will, that Arthur S. lost the summer’s struggle, considering he will be walking away with a whole lot of money.)

The history of the Demoulas rivalry is long and, at times, pretty ugly. It is highlighted by a court fight—complete with an actual courtroom fight between the two Arthurs, in which Arthur T. hit Arthur S.–that dominated business headlines in the 1990s.

The courts found that Arthur T.’s side of the family had defrauded Arthur S.’s out of its stake in the company after Arthur S.’s father died in 1971. The judgment swung control of the chain back to Arthur S.’s side.

However, even after Arthur S.’s side gained control, his sister-in-law continued to vote with Arthur T., keeping Arthur T. in control of Market Basket well past the wake of the judgment and its appeals. Her move to Arthur S.’s side in 2013 effectively led to the unfolding of recent history.

Arthur S. has also taken issue with real estate deals made by Arthur T. through Market Basket that benefitted Arthur T.’s side of the family—but have, for the most part, been found to be in-bounds. Arthur T. was also accused of defiance toward the company’s board while he was in charge.

All the animosity, drama, and litigation haven’t managed to keep the chain from success in recent years. Market Basket now operates 71 stores in New England and is reported to generate higher profit margins than its competitors—despite its low prices and investment in its employees.

The credit for the success is found in a few places, which are summarized here. Among them: Market Basket’s lack of debt. With Arthur T. and family now taking on debt to make the deal work, all eyes will be on whether it is possible for the company to operate as it has and still satisfy the terms of a financing plan. (The Boston Globe’s Steve Syre argues it won’t necessarily have an effect, for what it’s worth.)

For workers and customers, though, those are questions for another day. After the news broke, the Save Market Basket Facebook page, which is run by protesting employees and has been an organizing vessel for the movement, posted a statement celebrating the result and expressing excitement to get back to work:

“Tonight we raise a glass to Artie T and each other as we have achieved the most improbable of upsets. Tomorrow we go to work and never, in the history of people going to work, will so many people be so happy to punch the clock.”

The full statement released through a spokesperson for Arthur T. Demoulas:

Market Basket and its shareholders are pleased to announce today that the Market Basket shareholders have entered into a binding agreement pursuant to which the Class B shareholders will acquire the 50.5% ownership interest of Market Basket currently owned by the Class A shareholders.

Effective immediately, Arthur T. Demoulas is returning to Market Basket with day-to-day operational authority of the company. He and his management team will return to Market Basket during the interim period while the transaction to purchase the Company is completed. The current Co-CEO’s will remain in place pending the closing, which is expected to occur in the next several months.

All Associates are welcome back to work with the former management team to restore the Company back to normal operations.

The shareholders and the Company would like to thank Market Basket customers and partners for their strong support through the years. Our shared goal is to return Market Basket to the supermarket that its customers have come to rely on for service, quality and best prices. We look forward to seeing you at your local Market Basket.

Check out more Boston.com coverage of the Market Basket saga here.