Sears' chairman, Eddie Lampert, has won court approval to buy Sears out of bankruptcy and keep it from liquidating. The deal will save up to 45,000 jobs and keep more than 400 stores open.

Sears had been facing a possible liquidation since filing for bankruptcy in October.

The department store has been losing money and closing stores for years. Many employees and analysts blame Lampert for the retailer's decline.

Sears has been given its second chance.

On Thursday, a bankruptcy judge approved the sale of Sears to its chairman, Eddie Lampert, after a court battle that lasted several days, a representative for Eddie Lampert's hedge fund, ESL Investments, has confirmed.

Lampert and ESL previously won an auction to buy the 126-year old department store chain out of bankruptcy for more than $5.2 billion, but last month, Sears' unsecured creditors objected to the bid. Each side was given a chance to make their case in bankruptcy court.

Sears has been battling with a possible liquidation since October, when it filed for bankruptcy and Lampert stepped down as CEO.

"Over the last several years, we have worked hard to transform our business and unlock the value of our assets," Lampert said in a statement to the press at the time. "While we have made progress, the plan has yet to deliver the results we have desired, and addressing the Company's immediate liquidity needs has impacted our efforts to become a profitable and more competitive retailer."

Since then, American consumers have been lamenting the loss of what was at one point the world's largest store and considered to be an early innovator of the shopping landscape.

Keep scrolling to see the story of its downfall in photos: