Toshiba is selling its prized memory chip business for $18 billion to a group of buyers that includes Apple.

The Japanese conglomerate is offloading major assets to try to deal with a crippling financial crisis. The memory chip business is its crown jewel, which has attracted interest from major tech companies like Taiwan’s Foxconn.

But after a messy, months-long bidding process, Toshiba has picked a consortium led by U.S. private equity firm Bain Capital and backed financially by Apple, Dell and other U.S. and Japanese firms.

It wasn’t immediately clear how much of the 2 trillion yen ($18 billion) will come from Apple, which uses memory chips for iPhones, tablets and other devices. Multiple reports suggested its stake in the bid would be significant, but the company declined to comment.

Other U.S. tech companies putting money into the deal include flash memory product maker Kingston and data storage firm Seagate, according to Bain. Their willingness to support the deal highlights the importance of Toshiba’s chip business to the global tech industry.

Related: Japan Inc. aims to bail out Toshiba by buying chip business

The bidding process had been plagued by fears in Japan that the valuable technology could end up under foreign control. A tentative earlier deal for the chip business, which didn’t pan out, was led by the Innovation Network Corporation of Japan (INCJ), a state-backed fund.

The new arrangement will still have Japanese backing. Toshiba itself will put 350 billion yen ($3.1 billion) into the special company that’s being formed to buy its chip unit. And the INCJ and the Development Bank of Japan may also invest at a later date.

Toshiba said limited control from non-Japanese companies and the ability of the memory chip business to maintain its independence were among the reasons for choosing the Bain-led bid.

Related: Toshiba: Too big to fail?

The agreement may not be the end of the saga, however.

The Bain group fended off a challenge from U.S. data storage firm Western Digital, whose subsidiary SanDisk has a joint venture with Toshiba.

But Western Digital is still trying to block the deal. SanDisk filed new proceedings against Toshiba in international courts Wednesday, calling the deal a “retaliatory breach” of the joint venture agreement.

Toshiba shares dipped 4% in Tokyo on Thursday morning.

Toshiba’s woes deepen: U.S. firm tries to block key part of survival plan

Toshiba is selling the memory chip business get out from under a massive financial crisis threatening its very survival. The collapse of its U.S. nuclear unit Westinghouse, which filed for bankruptcy earlier this year, cost the storied Japanese company some $6.4 billion.

The loss forced Toshiba to report a negative net worth for the fiscal year that ended in March. If it doesn’t turn things around by the end of this fiscal year, its shares will be delisted from the Tokyo Stock Exchange.