Dov Charney‘s luck has finally run out — and American Apparel is likely headed for the sales block.

The controversial founder and CEO of American Apparel was ousted Wednesday by the retailer’s board, paving the way for a potential sale of the company, insiders said.

The board of directors cited “an ongoing investigation into alleged misconduct” that it initiated earlier this year, announcing that it had voted unanimously after its annual meeting Wednesday to fire Charney for cause.

While the board didn’t elaborate, sources said Charney’s personal conduct with women, which had been the subject of a string of sex-harassment suits by former female employees, was among the longstanding issues. The issues didn’t appear to be criminal or related to troubles with the company’s operations, sources said.

Shares of the struggling clothier surged as much as 22 percent to trade as high as 78 cents in early trades Thursday. Recently, the stock was up 7 percent at 69 cents.

Prior to the announcement on Wednesday afternoon, 45-year-old Charney didn’t respond to repeated messages from The Post, as unconfirmed speculation spread among insiders that a brewing conflict between him and the board might end with his ouster.

Another possible bone of contention, according to one source, was that Charney recently had been seeking ways to reverse the dilution of his ownership stake in the company, which had resulted from a March stock offering of $30.5 million to cover near-term debt payments.

“He was asking for advice on what to do about the situation,” according to one source, noting that the recent equity raise had diluted Charney’s stake in the company to about 27 percent — well below the minimum of 35 percent generally seen as necessary to retain control of a board.

Indeed, Charney’s dilution from the equity deal appears to have left him vulnerable in his final defeat after a string of close calls during previous liquidity crises for the company.

Charney, who founded American Apparel in 1998 as a T-shirt supplier, in some ways had been a retail visionary.

Courting controversy with smutty ads that featured young, scantily clad women in compromising positions, Charney produced his fashions at a factory in Los Angeles, championing “Made in the USA” clothing.

While Charney campaigned to legalize Mexican workers at his LA plant, the rest of the US clothing industry had moved its manufacturing to sourcing overseas.

But he was continually dogged by operational disasters, even as consternation about his personal behavior grew.

In 2009, American Apparel was forced to fire 1,500 undocumented immigrant workers at its Los Angeles factory following a federal raid, spurring manufacturing shortfalls that led to a major cash crunch. In 2013, the company’s loss widened to $106 million from $37 million a year earlier, partly because of software glitches at a new manufacturing facility.

“We take no joy in this, but the board felt it was the right thing to do,” said American Apparel director Allen Mayer, newly appointed as co-chairman. “Dov Charney created American Apparel, but the company has grown much larger than any one individual and we are confident that its greatest days are ahead.”

Firing Charney for cause will require a 30-day period to resolve under his contract, and could trigger defaults on debt obligations that could, in turn, force a sale of the company, insiders said.

Financial chief John Luttrell will serve as interim CEO while the company hires a search firm to replace Charney.

American Apparel only narrowly escaped getting taken over by lenders this spring, as a group of debt holders including Goldman Sachs demanded a $13.6 million interest payment on more than $200 million in obligations.

The racy clothing brand is now expected to attract a bevy of suitors, including private-equity firms as well as competing retailers.

“The only thing that’s been standing in the way of a sale has been Dov Charney,” according to one banker close to the situation. “People love the brand, and they hate him.”