YouTube users in Germany had for years been confronted with a red error graphic when trying to view videos ranging from the latest pop clips to films with GEMA-controlled background music

Streaming video platform YouTube on Tuesday said it had reached a deal with German music licensing organisation GEMA, ending a years-long battle that blocked users from watching many videos.

The agreement was essentially an undisclosed fee paid by YouTube each time the music is played online.

Under the deal, artists who are GEMA members will receive payment when one of their videos is viewed.

"Authors, composers and music publishers will be paid fairly, while our YouTube users will be able to enjoy their favourite songs," YouTube executive Christophe Muller said in a statement.

The deal was "a clear signal to all online platforms... authors must be fairly remunerated for the exploitation of their musical works," GEMA head of broadcast and online Thomas Theune said in a separate statement.

YouTube users in Germany had for years been confronted with a red error graphic when trying to view videos ranging from the latest pop clips to films with GEMA-controlled background music.

The Google subsidiary and the music rights organisation spent the time wrangling—at times in court—over how musicians should be paid for their work being streamed.

A previous licensing agreement expired in 2009, setting the scene for legal battles that continued until GEMA failed in a Munich court case against YouTube in January this year.

In that case, the group had demanded 0.375 euro cents for each time one of its members' songs was played.

GEMA said that Tuesday's deal covered future and past usage of its members' music, but said the two sides had not agreed whether YouTube or the individual uploader should be responsible for licensing.

Neither side released details of the amounts of money involved in the agreement.

In its statement, YouTube said that the deal would also cover its subscription service YouTube Red, which lets users watch ad-free videos and premium content for a monthly fee.