The controversial waka-jumping bill has passed its final hurdle to become law this afternoon, after more than 27 hours of debate in Parliament.
The legislation is designed to prevent MPs from ditching their party during a parliamentary term and was agreed to as part of coalition negotiations between Labour and New Zealand First.
Under the bill, lawmakers who quit or are expelled from their party will also be ejected from Parliament. Electorate MPs could seek to win their way back in through a by-election.
The Electoral (Integrity) Amendment Bill passed 63-57 with the support of Labour, NZ First and the Greens, with National and ACT opposed.
Justice Minister Andrew Little said no individual MP should be able to defy the decision of voters and change the proportionality of Parliament
"Voters and only voters... should determine the parties represented in this House."
Mr Little also criticised the National Party, saying some of its behaviour in opposition had gone "overboard".
"It's unfortunate that [National MP] Nick Smith... made attacks on officials and public servants of this country that were totally unacceptable and totally uncalled for."
On Wednesday, Dr Smith described the Justice Ministry officials who drafted the legislation as "buffoons".
Dr Smith told the House National would repeal the "obnoxious" and "draconian" law if it won the next election, calling it an affront to freedom of speech.
"This bill is a blunt tool to nail dissenters. It will make MPs more subservient and more party-robots.
"I hate it. I hate it for the crude power-grab that it represents. I hate it for the way that it will mute MPs free speech. I hate it for the way that it will tarnish this country's democratic reputation."
He described the "architect" of the legislation, NZ First leader Winston Peters, as "master-puppeteer making fools of us and a joke of this Parliament".
Mr Peters promptly hit back, describing Dr Smith's speech as "cant and pious bulldust".
"If a member of Parliament disagrees with his or her caucus, then they should resign and put it on the line in a by-election," he told MPs.
"And guess who did that? I did - so I'm not asking someone to do something different."
The bill has proved a major headache for the Green Party which has previously fiercely railed against similar legislation.
Green MPs have described it as a "dead rat" which they had to swallow and leader James Shaw told Parliament it was the "most difficult decision" the party had taken over the past year.
"This has not been easy for us... whilst we are uncomfortable with this bill, the provisions that we've negotiated... have gotten us to the point where we're willing to let this bill pass."