NEW YORK (Reuters) - A U.S. bankruptcy judge on Thursday approved Sears Holdings Corp Chairman Edward Lampert’s $5.2 billion takeover of the beleaguered retailer, allowing the department store chain to avert liquidation and preserve tens of thousands of jobs.

FILE PHOTO: A dismantled sign sits leaning outside a Sears department store one day after it closed as part of multiple store closures by Sears Holdings Corp in the United States in Nanuet, New York, U.S., January 7, 2019. REUTERS/Mike Segar/File Photo

Judge Robert Drain approved the sale after a hearing spanning several days in a White Plains, N.Y., federal bankruptcy court. He overruled objections, including from an unsecured creditors committee, which said the process for selling Sears was unfair to them and argued for a liquidation.

Lampert, who arranged an $11 billion merger between Sears and discounter Kmart in 2005 and tried for years to boost business, wins another chance to try to revive what once was the biggest U.S. retailer.

Lampert, the only bidder offering to keep Sears alive through his hedge fund, ESL Investments Inc, agreed to a deal for 425 stores after round-the-clock negotiations in January. The takeover aims to preserve about 45,000 jobs.

“I conclude that the process here was proper and appropriate,” Drain said in his reasoning for approving the sale.

Terms of the sale allow for some litigation to continue against Lampert and ESL.

Drain said Lampert was “subject to substantial verbal abuse” during the proceedings, noting that critics had characterized the Sears chairman in ways that evoked a ruthless robber baron and a blowhard sitcom character.

“He is a wealthy individual and a big boy and I guess he can take it,” Drain said, adding that some of the abuse may have been justified.

Sears Chief Restructuring Officer Mohsin Meghji and company directors Bill Transier and Alan Carr were among those questioned on a witness stand during the court hearing on Lampert’s offer.

Lampert stepped down as CEO when Sears filed for bankruptcy Oct. 15, though he remained the retailer’s chairman, largest shareholder and creditor. A restructuring committee of independent directors negotiated with Lampert and his advisers.

Drain grew impatient as the proceedings wore on Thursday. “Give me a break,” the judge said, when a creditors committee lawyer argued an objection to the takeover bid.

Hoffman Estates, Illinois-based Sears will still face fierce competition from big rivals including Amazon.com Inc and Walmart Inc. Founded in the 19th Century, Sears built itself into an American institution with its famous mail-order catalogs in practically every middle-class home. Its Sears tower in Chicago was once the tallest building in the world. But it failed to adapt to the modern era of online shopping.

When Lampert combined Sears and rival chain Kmart, the merged retailer had nearly 3,500 stores and employed more than 300,000 people, a workforce that shrank to 68,000 when it filed for bankruptcy.

Lampert’s offer came after the retailer had been pushed to the brink of liquidation multiple times. In the end, he boosted his initial offer by $800 million, largely in the assumption of Sears bills for taxes and merchandise.

Money owned to lawyers, bankers and other advisers working on the retailer’s bankruptcy case also proved contentious as Sears lacked enough money to meet all its obligations.

Lampert agreed to take on one of the company’s bankruptcy loans, which debtors typically repay, in its entirety. Lampert was allowed to use $1.3 billion Sears owed him as currency in the offer, a maneuver known as a credit bid, which some creditors had opposed. He received a legal release protecting him from litigation regarding money he loaned Sears.

Lampert still remains exposed to lawsuits related to certain transactions he engaged in while leading Sears before filing for bankruptcy. Sears directors rejected his request to receive a broader legal release covering those deals, which creditors contend robbed them of value.

Sears over the years spun off clothing manufacturer Lands’ End and parted with 235 of its best stores for $2.7 billion to a company Lampert created called Seritage Growth Properties

Drain intervened multiple times to urge Sears advisers and Lampert’s negotiators to keep working toward a deal.