The long, strange tale of HTC and Beats Electronics has come to an end.

HTC confirmed today that it has sold its 24.84 percent stake in Beats Electronics back to the company. The $265 million deal comes two years after HTC paid $300 million for half of Beats and a little over a year after it sold half of that investment back.

The move is a big deal for HTC, which is preparing to report the first quarterly loss in its history. Executives are jumping ship, its stock has hit eight-year lows, and it can’t even get enough parts for the phones it wants to make.

In other words, HTC needs all the money it can get.

But as HTC steps out of the Beats deal, Carlyle Group, an asset management firm, is stepping in. The company is investing $500 million in Beats, netting a minority stake in the company and two seats on the Beats board. This leaves Beats with a valuation of roughly $1 billion.

In a statement, Beats founder and CEO Jimmy Iovine said the deal represents “the evolution of the financial strength and significant growth prospects of Beats.” Likewise, Carlyle Group is betting on the continued success of Beats Electronics, which claims over half of the market for headphones costing more than $100.

VentureBeat's mission is to be a digital town square for technical decision-makers to gain knowledge about transformative enterprise technology and transact. Learn more about membership.