APPLE has agreed to splash out $3bn on Beats Electronics, the firm founded by hip-hop producer Dr Dre.
Although best known for their upmarket headphones, Tim Cook, Apple's chief executive, said Beats' music streaming service was the main selling point in the deal.
The growing popularity of streaming from sites such as Pandora and Spotify has eaten into iTunes downloads.
The deal - by far the largest acquisition in Apple's 38-year history - comes after three weeks of negotiations and means the Beats' co-founders, Dr Dre and recording impresario Jimmy Iovine, become key executives in Apple's music division.
"We have known these guys forever," Mr Cook said of them.
"We've dated, we've gone steady and now we are getting married. This relationship started a decade ago, so we know there is an incredible cultural fit. These two guys have a very rare set of skills. It's like finding a particular grain of sand on the beach. It's that rare."
With the rise of streaming, US sales of downloaded songs slipped 1% last year to $2.8 bn while streaming music revenues surged 39% to $1.4 bn, according to the Recording Industry Association of America.
Apple broke into streaming with the launch of iTunes Radio last September, but the service has not taken off.
The deal for Beats consists of $2.6 bn in cash and $400m in Apple shares and is expected to be completed before the end of September.
Beats was founded in 2008 by Dr Dre and Mr Iovine, a long-time recording industry executive who is currently chairman of Universal Music Group's Interscope Geffen A&M Records.
The luxury headphones have become firmly established as a key accessory for Apple products.
Update your news preferences and get the latest news delivered to your inbox.