"Apple Music and Shazam are a natural fit, sharing a passion for music discovery and delivering great music experiences to our users," Apple said in a statement.

London-based Shazam said in a separate statement: "We can't imagine a better home for Shazam to enable us to continue innovating and delivering magic for our users."

Shazam, which was founded in 1999 in the early age of online music, has offered a solution to a longtime agony of listeners -- putting a name to elusive songs. With a click, the app identifies tracks playing on the radio, at parties or as background music.

But Shazam has struggled to find a way to make money off its technology, even as it said that it had reached one billion downloads on smartphones last year.

Shazam only recently announced it had become profitable, thanks to advertising and steering traffic to other sites such as Spotify and Apple Music.

The technology is also no longer quite as novel, with Shazam facing rivals such as SoundHound and with smartphones capable of ever more advanced recognition functions.

Mark Mulligan, who writes a popular blog on the music industry, described Shazam as "cool tech without a business model" and said Apple was a rare player that could bring out the app's value.

FACING TOUGH COMPETITION

The world's most valuable publicly traded company, Apple earns most of its revenue from iPhones but has also found it vital to be seen on the cutting edge culturally.

Apple, which revolutionized online music a generation earlier with iTunes, in 2015 launched Apple Music as the market turns to streaming, which offers unlimited on-demand listening.

Apple said in September that the service had more than 30 million subscribers -- a quick rise, but still trailing Spotify.

Spotify -- which has emphasized a barebones, user-friendly interface instead of unique features -- said it had 60 million paying users as of July and 80 million more on its free tier.

And with streaming experiencing rapid growth, competition has become even fiercer.

Retail giant Amazon seized on its vast consumer reach as it launched its own streaming service last year.

YouTube, the video-sharing behemoth owned by Apple's rival Google, also has its own music streaming platform and recent reports said it was looking to launch a new paid subscription package next year.

TECH BATTLE TURNS TO SERVICES

Shazam has already proven it can be woven into another service. A year ago, it formed a partnership with SnapChat, the youth-driven social media platform whose videos evaporate, with users able to "snap" to friends the music they discover around them on Shazam.

Neil Saunders, managing director of GlobalData Retail, said the Shazam sale "underlines the fact that the battle of the technology companies is firmly moving beyond hardware and into services."

"This is a good move for Apple that helps to consolidate its already strong position in music content. It won't be the last takeover of a tech firm by these big giants," he said.

Apple has already invested in buying big-name music brands, in 2014 paying an eye-popping $3 billion for Beats Electronics, the headphones, speaker and streaming brand of rapper Dr. Dre.

Soon afterward, it bought Semetric, a British company that tracks music consumption on behalf of labels and artists.