AMSTERDAM (Reuters) - Dutch voters have narrowly rejected a law that would give spy agencies the power to carry out mass tapping of Internet traffic delivering a setback to Prime Minister Mark Rutte’s government.

Slideshow ( 2 images )

Dubbed the “trawling law” by opponents, the legislation would allow spy agencies to install wire taps targeting an entire geographic region or avenue of communication, store information for up to three years, and share it with allied spy agencies.

With 89 percent of the vote from a referendum counted on Thursday morning, the “no” vote was 48.8 percent, against 47.3 percent “yes.”

The tapping law has already been approved by both houses of parliament. Rutte’s government had backed a “yes” vote, saying the law was needed to make the country safer, and though the referendum was non-binding Rutte has vowed to take the result seriously.

If confirmed, it would be the third “no” to be voiced by the Dutch in a referendum after rejecting a European Union association agreement with the Ukraine in 2015 and the EU constitution in 2005.

An early exit poll by national broadcaster NOS had shown the yes camp narrowly winning.

Digital rights group Bits of Freedom urged the government to reconsider the law. “Voters have given a clear signal”, director Hans de Zwart said in a statement. “This law is not good enough and needs fundamental improvements.”

Bits of Freedom campaigned for a “no” vote, saying it feared privacy violations, although taps must be approved beforehand by an independent panel.

Before the vote, Rutte said the law was needed to prevent terrorist attacks.

“It’s not that our country is unsafe, it’s that this law will make it safer,” he said.