NEW YORK – A bankruptcy judge on Thursday blessed a $5.2 billion plan by Sears chairman and biggest shareholder to keep the iconic business going.

The approval means roughly 425 stores and 45,000 jobs will be preserved.

Eddie Lampert’s bid through an affiliate of his ESL hedge fund overcame opposition from a group of unsecured creditors, including mall owners and suppliers, that tried to block the sale and pushed hard for the company’s liquidation.

In delivering his decision, U.S. Bankruptcy Judge Robert Drain for the Southern District of New York rejected the group’s claims that the sale process was unfair and flawed, that it shut out any others who could have been interested in buying the business and that Sears had more value to its creditors if it died than if it lived.

The ghost of Toys R Us loomed large in the Sears bankruptcy case. The toy retailer was forced into liquidation last year just months after it tried to reorganize under bankruptcy court, wiping out 30,000 jobs.

During the hearing, which started on Monday, Drain focused on the specter of jobs. Lawyers for Sears and ESL argued that the sale offered the best alternative and also played up the need to save jobs.

Drain is expected to enter his order on Friday, making it official.

Even with this latest reprieve, Sears’ long-term survival remains an open question. Kunal Kamlani, president of ESL, shared his vision this week of building a network of smaller stores that highlights mattresses and major appliances, but the details are still lacking.

In fact, William Transier, an independent board member of Sears since October, acknowledged during the hearing that Sears could shutter an average of three stores per month and sell $600 million in real estate over the next three years. And the company still faces cutthroat competition from Amazon, Target and Walmart. This while its stores look old and drab.

“Major hurdles to its long-term business remain,” wrote Moody’s department store analyst Christina Boni, in a note published Thursday. “Scale, which is critical to competing in retail today, will be lacking and its core customer proposition still remains in question.”

Lampert steered Sears into Chapter 11 bankruptcy protection in October. The company’s corporate parent, which also owns Kmart, had 687 stores and 68,000 employees at the time of the filing. At its peak in 2012, its stores numbered 4,000.

Sears was hard hit during the recession and was unable in its aftermath to keep up with shifting consumer trends and strong rivals. It hasn’t had a profitable year since 2010 and has suffered 11 straight years of declining sales.

Lampert’s original plan was rejected by a subcommittee of the Sears board. ESL sweetened the bid several times before the subcommittee gave it the OK.

The group of unsecured creditors, who rank at the bottom of the list to be paid, filed objections to the sale, alleging falsified financial projections, excessive buybacks, and a spinoff of brands that stripped the business of key assets.

“The tortured story of Sears reads like a Shakespearean tragedy,” the group said. “Lampert and ESL managed Sears as if it were a private portfolio company that existed solely to provide the greatest returns on their investment, recklessly disregarding the damage to Sears, its employees and its creditors.”

Lampert personally owns 31 percent of the Sears’ outstanding stock, and his hedge fund has an 18.5 percent stake, according to FactSet. He stepped down as CEO in October after serving in that role since 2013.

Under Lampert’s watch, the Hoffman Estates, Illinois-based retailer has survived in part by spinning off stores and selling well-known brands like Craftsman tools. He has also lent some of his own money.

Lampert has been criticized for not investing in his stores. Even Sen. Elizabeth Warren, a Massachusetts Democrat and potential presidential candidate, has attacked him and questioned his commitment to Sears workers.

“I am concerned that under your leadership, Sears may continue to struggle and employees will continue to face uncertainty and anxiety over their future employment, and ongoing risks to their benefits and economic security,” Warren wrote in a letter to Lampert made available to The Associated Press by a worker advocacy group.

One of the lawyers for Lampert’s hedge fund testified earlier this week that the 56-year-old billionaire has been portrayed as a cross between J.Gould, the late railroad tycoon, and Barney Fife, a fictional character in the popular TV show “The Andy Griffin Show.”

Drain, the bankruptcy judge, acknowledged that Lampert had been subject to “verbal abuse.”

“He is a wealthy individual and a big boy,” Drain said. “And I guess he can take it.”

But he urged Lampert, who wasn’t in the courtroom, to have constant communications with the company and its employees.

Lampert “has an opportunity to not be a cartoon character …. He should do that,” Drain said.