WHITE PLAINS, N.Y. — A federal judge on Thursday approved a last-minute deal to save Sears Holdings in shrunken form, giving the death-defying retailer a second chance at life.

Judge Robert Drain authorized a deal to sell the major remaining assets of Sears to its chairman, largest shareholder and former CEO Eddie Lampert's hedge fund, ESL Investments.

Hours before Drain announced his decision, attorney Ray Schrock, who represents Sears, noted the gravity of the moment as closing arguments began.

“Today is obviously a very importan day for Sears,” he said to Drain. “The fate of Sears is going to be in the court’s hands.”

Putting Sears’ plight in the broader context of the entire retail industry, which has been disrupted by forces ranging from Amazon to the rise of fast fashion, Schrock said, “like so many retailers, it’s a melting ice cube, and the timing is urgent.”

As sales cratered over the last roughly 15 years, Sears has closed more than 3,500 stores and cut about 250,000 jobs, leading to the company's Chapter 11 bankruptcy filing in October.

Without approval of the sale to ESL, Sears would have almost certainly liquidated altogether.

Instead, about 425 stores and 45,000 employees will be transferred to ESL.

"The execution risk for this transaction, when one considers the alternative … is reasonable to take," Drain said.

Drain acknowledged that Lampert, who has been fiercely criticized for his role in the downfall of Sears, had been portrayed as a cross between the American railroad baron Jay Gould and bumbling fictitious character Barney Fife.

"During the course of this case, Mr. Lampert, in particular, has been subject to substantial verbal abuse," Drain said. "He has the opportunity now not to be a cartoon character and take action that in fact would be of great meaning" to the company's employees, vendors and shoppers.

Although the company will survive, store closures are not expected to stop altogether.

Sears and Kmart employees expressed both "a sigh of relief" and "grave concern" in a statement released on their behalf soon after the deal was approved.

"I'm relieved I still have a job, but the future of my family is back in the hands of Eddie Lampert, who has proven he only cares about his own wealth and does not care about our families and our livelihoods," said Victor Urquidez, assistant manager at Sears Auto Center, in the statement.

He urged Lampert to follow through in investing in stores, saying, "He needs to make sure that all employees who dedicated years to the company and whose jobs he destroyed get financial support for themselves and their families.”

While Lampert's ESL will obtain ownership of the company's 425 remaining locations, ESL President Kunal Kamlani testified Wednesday that about 156 are not performing well.

Under the deal, ESL would offer $5.2 billion including an $885-million cash payment. It will also assume $1.3 billion of liabilities including customers’ warranties and paying off $621 million of senior debt.

The hedge fund's deal to acquire Sears does not preclude it from further cuts.

Greg Portell, partner and retail adviser at consultancy A.T. Kearney, said the company probably has about 200 stores that can be successful.

"I would advise them to get smaller," Portell said. "Get smaller and create a foundation from which you can grow, as opposed to a foundation which erodes."

Lampert, who relinquished the CEO role when the company filed for bankruptcy, was the company's largest shareholder and creditor at the time of the bankruptcy.

That means he had the most to lose and the most to gain as the company faced a do-or-die scenario.

A group of unsecured creditors argued the sale unfairly favors Lampert, characterizing the offer as part of a long-running “scheme” to drain the company.

“He set up a process where there was no alternative but ESL,” said Abid Qureshi, attorney for the creditors. “This entire process was set up to fail.”

But Drain disagreed. “It is clear to me that all told, ESL conducted itself…in good faith,” he said.

Drain, according to court testimony, wanted to preserve jobs if at all possible.

"We intend for the new company to operate as many Sears and Kmart stores as reasonably possible, including new smaller stores that emphasize our stronger capabilities. Continuing to operate a meaningful network of stores is essential to achieving our goal of returning Sears to profitability," ESL said in a statement earlier this week.

Sears attorney Schrock has said previously that if the deal were approved, it could be finalized on Friday.