It's official: Apple is buying Beats.

Ending weeks of speculation, Apple announced today it will purchase headphone maker Beats Electronics and its subscription service Beats Music in a deal worth $3 billion.

The deal is the largest known acquisition made by Apple, comprising $2.6 billion in cash and $400 million in Apple stock that will vest over time. The transaction is expected to close before the end of September.

As part of the deal, Beats co-founders and music industry veterans Dr. Dre and Jimmy Iovine will join the consumer tech giant's ranks.

Related: Music Mogul and Entrepreneur Dr. Dre: I'm the 'First Billionaire in Hip Hop'

Iovine said the move is a natural fit for the company. "I’ve always known in my heart that Beats belonged with Apple,” he said in a statement. “The idea when we started the company was inspired by Apple’s unmatched ability to marry culture and technology."

Founded in 2008, Beats was once majority owned by phone maker HTC. HTC sold nearly half of its stake in July 2012 for about $150 million, and the remainder for $265 million last fall. The Santa Monica, Calif.-based company also received a $500 million investment from private-equity firm Carlyle Group in September.

Related: Here's How to Quit the iPhone and Switch to an Android