American Apparel has ended its downward financial spiral for the time being by filing for Chapter 11 bankruptcy protection only two months after warning that it lacked the money to stay afloat.

The filing is a major setback to its controversial CEO Dov Charney, who had been accused of sexual harassment by former employees and the company. Charney denies the charges.

Charney owned about 42% of the company, but signed over the bulk of his stake to hedge fund Standard General, which he believed he had teamed up with to take over the company. Standard General now holds his stake as collateral, according to Reuters.

Bankruptcy filings also by their nature wipe out the ownership of all shareholders, so Charney's stake in the company is, either way, worthless. He also can't buy any shares in at least the next six months as the company reorganizes.

That's meaningful because Charney had hoped to take back control of American Apparel, raising his stake to as high as 43% in 2014, which put him very close to being able to take over the company. American Apparel responded by adopting a "poison pill," which floods the market with shares when anyone tries to take a large stake. That left Charney at an impasse.

Charney launched series of lawsuits against the company and its investors, including a $30 million lawsuit against Standard General, one of the company's biggest shareholders, for defamation. He suggested there was a conspiracy at work as the hedge fund fooled him into giving up his seat on the company's board and control of most of his stock.

American Apparel hinted that Charney's lawsuits were a factor in the bankruptcy filing, suggesting a reorganization would help handle a "significant litigation overhang resulting from its former chief executive officer's misconduct and lawsuits he has brought against the company."

The bankruptcy filing is primarily a financial measure to allow American Apparel to handle its heavy debt load. The company owes nearly $400 million, but only has under $200 million in assets. The bankruptcy will clear at least $200 million of the company's bonds, and in return, American Apparel will give an ownership stake in the company to some of its creditors.

The company, based in Los Angeles, will stay in business in the United States. It will close some stores. The company said that its U.S. bankruptcy filing won't affect its operations in 18 other countries.

It expects to be fully reorganized within six months.

American Apparel has lost money every year since 2010, with revenue wilting as competition from fast-fashion retailers has increased.

Paula Schneider is now the company's CEO and said the reorganization would help the company's "turnaround strategy," including a new marketing plan. Executive Mark Weinsten will oversee the restructuring; Weinsten, with turnaround firm FTI Consulting, previously helped turn around Filene's Basement and Sirius Satellite Radio.

Shares of American Apparel went into freefall, plunging more than 24% before the stock market opened.

Additional information from the Associated Press