After lengthy negotiations, Toshiba this morning officially agreed to sell its lucrative memory chip unit to a global consortium that includes Apple, in a deal reportedly worth $17.7 billion (via The Wall Street Journal).

Toshiba said the legally binding agreement ensures the chip unit will remain a Toshiba affiliate even after it has become the property of the Bain Capital-led group, which includes Apple, Dell, Seagate, Hoya, and SK Hynix.

Toshiba and Bain want to get the deal done by the end of March, despite ongoing litigation with Western Digital, which jointly operates the memory business with Toshiba. Western Digital claims it has the right to vote on the sale. Another hurdle is receiving antitrust clearance, which could take six months or longer, according to WSJ.

Toshiba originally announced it would sell its NAND flash memory unit in January 2017 to raise funds to cover huge losses associated with its U.S. nuclear subsidiary, Westinghouse. Toshiba wants to close the deal to raise the cash by March so it can remain listed on the Tokyo Stock Exchange.

Several companies, including TSMC, Foxconn, Amazon, Google, Broadcom, and a range of private equity firms entered bids this year in an effort to get a piece of the memory chip unit.

In a statement given to Reuters on Thursday, SK Hynix said the Bain-led group will hold 49.9 percent of the voting rights in the chip unit, while Toshiba will hold 40.2 percent and Japan's Hoya Corp will own 9.9 percent. Apple, Dell, Seagate, and Kingston Technology will invest in the form of non-convertible preferred shares, it said.

SK Hynix also revealed it will invest 395 billion yen ($3.5 billion) in the unit. Other companies declined to comment, but individual investments are believed to be 350.5 billion yen ($3.11 billion) from Toshiba, 212 billion yen ($1.88 billion) from Bain, and a combined 415.5 billion yen ($3.68 billion) from Apple, Dell, Kingston, and Seagate.

Apple has been interested in the memory chip unit because NAND flash is an essential component of its iPhones and iPads. Only a handful of companies make the chips and the dominant player is Samsung, Apple's biggest rival in the smartphone industry.