Even in the digital era there are plenty of music fans who still buy old-fashioned compact discs for more than $10 a pop. But the money that shoppers have been spending on CDs lately hasn’t necessarily been going to the artists and record labels who created the music.

In the latest challenge for the battered music industry, pirates are flooding Amazon.com Inc. and other online retailers with counterfeit CDs that often cost nearly as much as the official versions and increasingly are difficult to distinguish from the real goods....