Sears will stay alive, for now. The company’s chairman Eddie Lampert won a bankruptcy auction in the early morning hours Wednesday, beating out bids from liquidators, multiple media outlets reported.

Over the last few days, Lampert upped his bid to more than $5 billion through an affiliate of his hedge fund ESL. The plan has to be approved by the bankruptcy judge overseeing the court case. That means the company’s roughly 400 remaining stores, including a dozen in Massachusetts, might all remain open. Tens of thousands of people would also be able to keep their jobs.

Twelve Sears locations are left in Massachusetts, eight of which are Sears Stores with an accompanying Sears Auto Center and three of which are Sears Appliance Outlets.

  • Auburn – Sears Store, Auto Center
  • Braintree – Sears Store, Auto Center
  • Brockton – Sears Store, Auto Center
  • Fall River – Sears Appliance Outlet
  • Hanover – Sears Store, Auto Center
  • Holyoke – Sears Appliance Outlet Stores
  • Leominster – Sears Store, Auto Center
  • Marlborough – Sears Store, Auto Center
  • North Attleboro – Sears Store, Auto Center
  • North Dartmouth – Sears Store, Auto Center
  • Saugus – Sears Store, Auto Center
  • Shrewsbury – Sears Appliance Outlet Store

Sears filed for Chapter 11 bankruptcy protection in October. At that time, it had 687 stores and 68,000 workers. At its peak in 2012, it had 4,000 stores.

The future of Sears and its Kmart brand have been discussed in Manhattan since Monday after a bankruptcy judge last week gave the company one last chance to survive. Sears was reportedly very close to liquidating. While the exact details of the rescue plan weren’t immediately known, Lampert’s bid on Tuesday reportedly included some concessions, including more cash.

Bloomberg News reported the bid was sweetened by more than $150 million over the last offer. One of the major sticking points in negotiations was over whether Lampert should be insulated from lawsuits over his past turnaround agreements. Such a release was reportedly not in Wednesday’s deal.

Lampert, who took control of Sears in 2005, was the only person to put forth a proposal to save the struggling chain in its entirety, according to The Associated Press. He has said publicly he wanted to rescue the company because he thinks it can still succeed.

“For as long as I have been involved with Sears, I have cared deeply about the company, its associates and the people they serve,” Lampert said in a statement sent through ESL to AP. “While the opportunity I saw from the start for Sears to benefit from the disruptive changes in retail and technology has not worked out so far, it is still there to be taken. Every transformation involves perseverance and risk, but I am hopeful that we can execute better and faster on the smaller platform we are bidding on … There is every reason to fight for its future.”

Sears’ most recent store closures were announced on Dec. 28, the same day Lampert made his bid for the company.