The federal Supreme Court dismissed two cases brought by music rights society GEMA against Deutsche Telekom and music companies Universal Music, Sony and Warner Music Group against Telefonica's O2 Deutschland.
It said on Thursday the plaintiffs did not make enough effort to halt the copyright violations in the first place but it said Internet service providers could in principle be held responsible for blocking music illegally available on the Internet, even if the content remained available elsewhere.
GEMA, which acts to protect the rights of the owners of musical works, had demanded that Deutsche Telekom, Germany's largest telecoms company, block the website "3dl.am" because it offered access to copyright-protected music.
In a separate case, the music companies wanted O2 Deutschland to block access to "goldesel.to," part of the eDonkey network, a peer-to-peer file-sharing network for music.
The court said in its ruling: "The company that offers Internet access will only be held responsible for blocking the site when the copyright holder has first made reasonable efforts to take action against those who have themselves infringed their rights, like the website operators, or those who have enabled the infringement, like the Web hosting providers."
The music industry says it loses billions of dollars every year from the illegal downloading of songs, depriving it of the revenue it needs to pay songwriters, artists and talent scouts.
Courts around the world are grappling with the question of who is responsible for copyright infringement through illegal downloads. Google's YouTube, for example, has been the subject of multiple court cases.
A German court ruled in July that YouTube was only responsible for blocking copyright-infringing videos when they had been brought to its attention, and could not be expected to scan everything on the site.
Deutsche Telekom welcomed the court ruling.
"The Supreme Court has clearly stated that with regard to Internet service providers the reasonableness of a potential blocking has to be subject to strict scrutiny," the company said in a statement.
Bernhard Rohleder, director of IT industry group Bitkom, said: "The blocking of websites should remain the last resort of network policy. As a measure against copyright infringement, it is quite excessive."
© Thomson Reuters 2015