After months of speculation, SunEdison (SUNE) filed for Chapter 11 bankruptcy protection in the Southern District of New York on Thursday.

"Our decision to initiate a court-supervised restructuring was a difficult but important step to address our immediate liquidity issues," CEO Ahmad Chatila said in a statement released Thursday.

According to court documents, as of Sept. 30, 2015, SunEdison had $20.7 billion in assets against $16.1 billion in debt, which is largely unsecured. As the company has not yet released audited financials for 2015, it is possible that its liabilities could be greater due to pending litigation the company faces from investors, companies it has attempted to acquire and even its own yieldcoTerraForm Global (GLBL). 

In Thursday's statement, the company said that the yieldcos, TerraForm Power (TERP) and TerraForm Global, were not part of the Chapter 11 filing. Shares of TerraForm Power rose as high as 9% following the news while TerraForm Global gained as much as 13%.

As part of its restructuring process, SunEdison secured as much as $300 million in debtor-in-possession financing from first and second lien creditors. The financing, which is subject to court approval, is expected to be used to help the company maintain operations. SunEdison has retained Skadden, Arps, Slate, Meagher & Flom as its legal advisor in this process.

The demise of the Missouri-based renewable energy company had been well-documented since July, when it announced plans to acquire Vivint Solar (VSLR) - Get Report in a transaction initially valued at $2.2 billion.

At the time, the market and analysts reacted to the proposed merger with skepticism, as the company had embarked on a buying binge that saw its debt balloon to $11.6 billion from $6.9 billion in less than a year. The stock began its steep decline from $32 when the deal was announced. The transaction was viewed as one too many, and Vivint's portfolio of residential assets was considered to be incompatible with -- and inferior to -- the commercial projects SunEdison and its yieldcos, TerraForm Power (TERP) - Get Report and TerraForm Global  (GLBL) , typically took.

Behind the skepticism, however, lurked something potentially more sinister. It wasn't just a question of whether or not SunEdison had the cash to complete the deal, it was also a question of whether SunEdison had enough liquidity to remain solvent. Also, investors wondered about the independence of SunEdison's yieldcos, as TerraForm Power was expected to buy as much as $900 million of Vivint's assets. The situation was only made worse after the company made sweeping changes the yieldcos' boards in November. (The changes were referred to as the "Friday Night Massacre" in one of the lawsuits against SunEdison). 

Ultimately, the merger failed in March with Vivint backing out of the transaction, citing SunEdison's failure to consummate the deal.

SunEdison is now subject to several lawsuits tied to its financial dealings. One lawsuit is from Vivint, tied to the failed deal, and another is from David Tepper's Appaloosa Management, which has a 10.9% stake in TerraForm Power. There are also two lawsuits from investors filed in California that alleged SunEdison made "untrue statements of material fact" in its offering documents drawn up to raise $2.5 billion between June 2015 and August 2015.

Perhaps the most damaging was the suit TerraForm Global filed against its parent company earlier this month, accusing SuneEdison of misappropriating $231 million. Instead of funding renewable energy projects in India, the suit alleges that SunEdison used the funds to "prop up its flagging liquidity position." The suit came days after TerraForm Global warned, via a filing with the Securities and Exchange Commission, that there was "substantial risk" that SunEdison would seek bankruptcy protection.

The lawsuits at times garnered more attention than the company's financials because the company has so far failed to release its 10-K for 2015. Allegations made in the suits provided some insight into just how tenuous SunEdison's financial standing might be.

SunEdison said in SEC filings that part of the reason for the delayed 10-K was due to an internal investigation into its financial controls. Last week the company said that the internal investigation showed no "fraud or willful misconduct" from its executives. That said, the executives were called out for being "overly optimistic" about its cash forecasting. SunEdison is still subject to investigations by the Justice Department and the Securities and Exchange Commission of its financial transactions.

A day after SunEdison announced the results of its internal investigation, it released a presentation it provided to its creditors in March. The presentation was used to help the company secure up to $310 million in debtor-in-possession financing. (DIP financing is typically used by companies to maintain operations while going through a chapter 11 or similar restructuring process.)

Although audited financials were not released, the confirmation of the DIP-talks meant that a filing was only a matter of time.