American Apparel is girding for a nasty battle with its controversial founder, Dov Charney.

The board of the struggling clothing chain has hired boutique investment bank Peter J. Solomon as a financial adviser as it braces for blowback from its surprise move to oust Charney as CEO, The Post has learned.

Charney is looking to corral shareholder support to take back the reins, according to sources. While he can’t oust current directors, he’s angling to gain a voting majority by packing the seven-member board with additional seats.

“Dov isn’t going down without a fight, and there’s an argument to be made that the board has overreached,” said a source close to the situation.

The board blitzed Charney at a Wednesday meeting, citing personal-conduct issues. The board offered Charney, who has weathered sex-harassment allegations from female employees for years, a four-year consulting contract that he turned down, according to insiders.

Charney, whose stake was diluted to 27 percent from more than 40 percent following a $30 million equity raise in March, is looking to additional investors to gain a shareholder majority to demand as many as four extra directors, insiders said.

Among Charney’s likely supporters, sources said, are FiveT Capital, a Swiss hedge fund that had scooped up nearly 13 percent of the company as of April, according to securities filings.

Complicating matters Thursday, lender Lion Capital exercised a right to take two seats on the retailer’s board under the terms of a $15 million term loan it has extended to the company, sources told The Post.

Theoretically, sources said Charney could assemble a majority with the support of Lion and between two and four additional directors, depending on whether he can get support from an existing director.

If successful, such a move could nearly double the size of American Apparel’s board to 13 members, including the two new seats claimed by Lion.

One source close to the board said Charney could “potentially” pull off such a gambit, but cautioned that “it’s a lot more difficult than he may think.”

Charney declined to comment.

It’s not clear whether Lion would side with Charney, who remains a director, or take issue with the board’s move to fire the company’s controversial CEO and strip him of his chairman title.

Lion CEO Lyndon Lea has a history of supporting sometimes eccentric retail visionaries including Charney under previous financing deals. Lea’s fashion-focused investments have included John Varvatos, Jimmy Choo and AllSaints.

Having claimed board seats, UK-based Lion also could elect to demand immediate payment of the principal, creating a potential liquidity crunch for the cash-strapped retailer.

Indeed, sources said American Apparel’s board has hired Solomon mainly in case it needs to raise money to pay off the loan from Lion, likely through an issuance of fresh stock.

In 2009, Lion extended a term loan worth more than $80 million to help American Apparel through a liquidity scrape.

That loan was paid off late last year, but soon thereafter Lion extended the current $15 million loan, which gives it the right to throw the retailer into default in the event of a CEO change.

Lion declined to comment.

American Apparel has no immediate plans to pursue a sale of the company, according to a source close to the board.

Nevertheless, banking sources said the company appears to be primping itself for such a possibility with the hiring of a bank and the ouster of Charney.