The law now explicitly allows the Government Communications Security Bureau to spy on New Zealanders in cases when the agency has a warrant from a domestic agency.
The contentious change was passed in a 61-59 vote on party lines, and the law is likely to take effect in late September.
Supporters said the bill helped clarify a legal gray area while opponents said 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.