Pandora Media won a battle in its continuing war with the music industry over royalties when a federal judge ruled on Tuesday that the American Society of Composers, Authors and Publishers, which represents thousands of members, cannot prevent Pandora from licensing all the songs in its catalog.

The ruling, by Judge Denise L. Cote of United States District Court in Manhattan, is a blow to music publishers, who have tried to get the best royalty rates for digital music by limiting the extent that performing rights societies like Ascap and Broadcast Music Incorporated represent their songs. The ruling could also hurt the societies themselves if they are perceived as preventing the publishers from getting higher rates.

Two years ago, the industry’s biggest publishers began withdrawing digital rights to their music from Ascap and BMI, forcing companies like Pandora to negotiate directly for a license to stream the music.

Sony/ATV, the world’s largest publisher, has said it received a 25 percent higher rate by licensing its songs to Pandora directly.