WELLINGTON, New Zealand (AP) — New Zealand has passed a law that strengthens the powers of its foreign spy agency.

The law change proved contentious in the South Pacific nation. Lawmakers passed it Wednesday in a 61-59 vote on party lines.

The law explicitly allows the Government Communications Security Bureau to spy on New Zealanders in cases when the agency has a warrant from a domestic agency.

Supporters say the bill helped clarify a legal gray area while opponents say it's an unwarranted expansion of the agency's powers.

The law change arose after the agency concluded that it had unlawfully spied on indicted Internet entrepreneur Kim Dotcom before his 2012 arrest.

Dotcom was born in Germany but had become a legal New Zealand resident.