After years of delay, Spain is finally enforcing a long-mooted anti-piracy law.

The first move by any Spanish government to crack down on piracy, the new law authorizes Spanish courts to order Internet service providers to shutter or block file-sharing sites that facilitate unauthorized movie and music downloads for profit.

Announced in 2009, the law was passed by parliament Feb. 15, but lacked enabling regulation to be put into practice.

That regulation was approved Friday by Spain’s new center-right Popular Party, after only five days in office.

The law follows years of U.S. protests against government-tolerated piracy in Spain that has decimated its local music industry, withered its DVD market, and dented box office receipts for Hollywood blockbusters.

Nielsen estimated in 2010, that 45% of Spanish Internet users visited illegal music distribution services vs. 23% in the top five European markets. Recorded music sales — physical and digital — in Spain in 2010 stood at $159 million, 13% of Britain’s sales.

Spain’s new law could have gone further. In marked contrast to France, where recidivist pirates can have their Internet connections cut, Spain’s new rulings do not punish end-users who download unauthorized content for enjoyment, effectively decriminalizing consumer piracy.

But local industry execs view the law as a step in the right direction.

“The best thing is the message the law sends out to file-sharing sites,” Antonio Guisasola, prexy of music producers’ assn. Promusicae, told newspaper El Mundo. “The worst,” he added, “(is) the lack of measures to educate end-users.”