It’s been a long, strange trip to bankruptcy court for Sears — and you can thank a brilliant, reclusive and woefully misguided hedge-fund manager for the ride.

The 125-year-old retailer — for decades one of the nation’s iconic corporations, selling everything from TVs to dresses to riding mowers — filed for bankruptcy early Monday, as shoppers fled its increasingly shoddy stores in favor of younger rivals like Walmart and Amazon.

More stunning, however, is the odd saga that Sears has endured for more than a dozen years now. In 2005, a financial prodigy named Eddie Lampert seized control of Sears by merging it with Kmart. For a while, the surprise deal was the talk of Wall Street, with many reckoning that Lampert was destined to become the next Warren Buffett.

Instead, Sears got crippled by Lampert’s bizarre approach to running the Chicago-based company, which included micromanaging it from his mega-mansions in Connecticut and Florida, flitting between flopped retail experiments and flouting the industry’s basic conventions for investing in stores.

“This guy pivoted from being a successful hedge fund manager to running a retail empire,” said Mark Cohen, a former chief executive of Sears Canada who’s now director of retail studies at Columbia Business School. “But he never viewed anyone’s opinion but his own as valuable.”

Now, 56-year-old Lampert is scrambling to salvage 300 locations from what, before his arrival, had spanned more than 3,500 Sears and Kmart stores. Experts disagree whether the aging chains could have thrived on somebody else’s watch, but one thing is clear: Lampert isn’t the genius that many deep-pocketed investors thought he was.

In its early Monday Chapter 11 filing, Sears said it got $300 million from lenders to keep shelves stocked and employees paid through the holidays, but that it was still in talks with Lampert, who stepped down as CEO, to get as much as $300 million more.

In words that rang eerily familiar to longtime followers of Sears, Lampert said his hedge fund “will continue to press forward with the goal of seeing Sears emerge from this process positioned for success.”

The slow-moving train wreck began in 2003, when Lampert startled investors by scooping Kmart out of bankruptcy through an $800 million debt investment. Most had viewed Kmart as hopeless, but Lampert soon cut a deal to sell 70 of its 1,400 stores to Sears and Home Depot for $900 million. Kmart shares leaped, suddenly making Lampert’s $800 million bet worth more than $4 billion.

Lampert — a numbers whiz whose college roommate at Yale was Treasury Secretary Steve Mnuchin, and who only a few years later worked for ex-Treasury Secretary Robert Rubin at Goldman Sachs — was now a Wall Street celebrity. A who’s who of A-list investors — the Tisch family, the Ziff publishing heirs, Michael Dell and Mnuchin — poured into Lampert’s Connecticut-based hedge fund, ESL Investments. David Geffen gushed that he had made more money with Lampert than in all his years as a music mogul.

Notoriously tight-lipped and stingy with interviews, Lampert’s mystique only grew in 2003 when he got kidnapped and held hostage in a motel bathroom for 30 hours before talking his way out of the fix. Just days after he was released by captors on an I-95 exit ramp near ESL’s offices, Lampert was back negotiating the Kmart deal. His next big move: the $12 billion deal in 2005 to buy Sears with Kmart’s surging shares.

Then as now, Sears and Kmart both were among the dingiest, dowdiest and aged retail brands in the US. Yet merged together as Sears Holdings, they quickly became the sexiest story on Wall Street as pundits scrambled to guess Lampert’s thinking. As the new chairman, Lampert nixed quarterly conference calls, instead firing off annual, Buffett-style shareholder letters. Declaring that he worked for investors, not shoppers, Lampert railed against the traditional tenets of retailing, yanking yearly budgets for remodeling and staffing stores that he insisted were wasteful.

For a while, the unorthodox tactics seemed to work. Profits soared as Sears slashed fixtures, inventory and hours for sales associates. Meanwhile, analysts outdid each other with ever-growing estimates of Sears’ real estate value. By early 2008, Merrill Lynch and Morgan Stanley were pegging it at $16 billion — more than the company’s $14 billion market cap at the time.

A year later, however, the financial crisis had hit, leaving shopping malls with one of their worst Christmas seasons in a generation. As department stores slashed prices to clear unsold goods, big names like Macy’s, JCPenney and Saks Fifth Avenue began shuttering locations, undermining the idea that Sears’ property was a gold mine.

Lampert, meanwhile, had been jumping from one oddball turnaround strategy to the next. He obsessed over competing with Amazon, but refused to spend big on Sears’ web business. After proposing and ditching a number of new store formats, Lampert quietly divided Sears Holdings into more than 30 different corporate silos, encouraging the head of each to compete for resources with the others, “Hunger Games”-style.

It sounded like something out of a novel by Ayn Rand, the capitalist philosopher whose 1943 novel “The Fountainhead” became the namesake of Lampert’s 288-foot yacht. But to investors, it sounded alarming. Geffen got out in 2007, while the Ziff family exited in 2011. By 2013, a group of Goldman Sachs’s pension-fund clients who had poured more than $3.5 billion into ESL were demanding their money back.

In 2011, Sears had begun to hemorrhage cash as shoppers fled its increasingly rundown stores in droves. To offset losses, Lampert began selling assets. In 2014, Sears spun off Lands’ End. A year later, it raised $2.7 billion by selling more than 200 stores to Seritage Growth Properties, a real estate company backed by Lampert. In January of this year, Sears sold its Craftsman tool brand to rival Black & Decker for $900 million.

By then, the asset sales didn’t seem as clever as they did when Lampert sold that first handful of Kmart stores for nearly $1 billion. In recent weeks, Lampert tried and failed to convince his own board to sell him the Kenmore appliance brand for $400 million, and a chunk of Sears’ remaining real estate for $1.5 billion. The deals would have enabled Sears to avert Monday’s bankruptcy, but board members feared Lampert’s conflicted position would spur lawsuits from lenders.

Sears’ bankruptcy filing “has the potential to get very messy,” Stephen Opper, a distressed-debt analyst at Reorg Research, told The Post. “He owns the debt and the equity and he’s been involved as a manager of the company, which raises questions and red flags.”

Lampert’s early, spectacular success finding value in Sears and Kmart’s assets has kept investors wondering how he is making out, even as he runs the businesses into the ground. After spending billions buying back shares that are now worthless, Lampert also has become the company’s biggest creditor, most recently extending it a $500 million loan in January.

Still, despite financial jockeying that will give Lampert sway over bankruptcy proceedings, picking through what remains of Sears and Kmart isn’t likely to yield him anything close to what he would have gotten if he had simply thrown the $15 billion ESL had in 2006 into a stock-index fund.

In 2006, Lampert’s net worth was estimated at $3.8 billion by Forbes, just north of Amazon founder Jeff Bezos’ at the time. This year, the magazine estimates Lampert is worth just $1 billion. Bezos is now worth more than $160 billion.

Meanwhile, thousands of workers at 142 Sears and Kmart locations will be looking for new jobs after the holidays. Among stores slated for closure is the Sears at the Jefferson Valley Mall in Yorktown Heights, NY. A few months ago, the retailer had moved out of the bottom floor of its two-story space to make way for a fitness gym. Squeezed into the second floor, women’s pajamas now hung opposite Kenmore appliances.

One sales associate, a 14-year veteran of the company, frowned when asked if she recognized Lampert’s name, noting that employees no longer get 20 percent discounts on apparel and 10 percent discounts on appliances and tools.

“To some people here, you can’t mention his name,” the associate said, hiding her ID badge and declining to give her own name. “They are mad about what he’s done to Sears.”