BERLIN — In a provisional victory for musicians, filmmakers and other creators of art and entertainment, a court in Hamburg on Friday ordered Google to install filters on its YouTube service in Germany to detect and stop people from gaining access to material for which they do not own the rights.

The judge, Heiner Steeneck, agreed in his ruling that Google was not directly responsible for the uploaded material. But he said the company needed to do more to stop violations.

“This is a victory along the way to what will be a very important case,” Peter Hempel, a spokesman for GEMA, the German association that levies and collects royalties on recorded media. “This case, when it is eventually decided, will set a precedent for the legal responsibilities of online platform operators such as Google in Germany.”

The judge rejected a request by GEMA that Google sort through its entire online music archive and purge its system of all copyrighted material.