The battle between Amazon and Apple took another turn Thursday when Amazon said iPhone and iPod Touch users will be able to buy music from its digital store for the first time.

Amazon.com Inc. said Thursday that its MP3 library has 22 million songs available.

Steve Boom, vice president of Amazon Music, says that since the launch of the Cloud Player app for the iPhone and iPod Touch, customers have been asking for the ability to buy music from Amazon directly from their devices.

The Apple device users can browse Amazon’s MP3 store for music using Apple’s Safari Web browser. Music users buy gets saved to their Amazon Cloud Player libraries and can be downloaded or played instantly from Apple devices or other gadgets such as the Kindle Fire.

Just a week ago, the largest online retailer said it would offer digital copies of CDs bought on its site, as it competes with Apple Inc. and Google Inc. to attract music lovers choosing to store their music on the Web.

The new service, called Amazon AutoRip, gives access to free MP3 versions of tracks from an initial batch of 50,000 albums, including “Overexposed” by Maroon 5 and Pink Floyd’s “The Dark Side of the Moon,” Amazon said. The service is retroactive, so anyone who has bought CDs from Amazon since it started selling music in 1998 can claim a copy.

While Amazon was the first company to move music to the cloud — storing content on the Internet for access on any device — its Cloud Player is still trailing Apple’s iTunes and has new rivals in Google and Spotify Inc. In the second quarter, Apple had 64 percent of the market for digital music, compared with 16 percent for Amazon and 5 percent for Google, according to research firm NPD Group Inc.

(The AP and Bloomberg contributed to this report.)