The European Parliament rejected a global agreement against copyright theft on Wednesday, handing a victory to protesters who say the legislation would punish people for sharing films and music online.

The vote marked the culmination of a two-year battle between legislators who supported the Anti-Counterfeiting Trade Agreement (ACTA) and it's largely young, digitally savvy opponents.

Tens of thousands of activists held rallies across Europe in February to protest against the law, which they said would curb their freedom and allow officials to spy on their online activities. About 2.5 million signed a petition against ACTA.

European Parliament lawmakers voted against the agreement by 478 to 39 with 165 abstentions, meaning the proposed law will have to be renegotiated by the European Commission, the EU's executive.

European Parliament President Martin Schulz said in a statement after the vote that legislators were not against intellectual property rights but that ACTA left too much room for abuses and raised "concern about its impact on consumers' privacy and civil liberties, on innovation and the free flow of information".