Legislation that would have limited superannuation payments for people who had not worked their whole life in New Zealand has narrowly failed.

Parliament descended into a mud-slinging match last night as MPs traded personal insults while debating the members bill.

The bill, in the name of New Zealand First's Denis O'Rourke proposed a pro-rata entitlement to superannuation based on how long someone had lived in New Zealand between the ages of 20 and 65 years.

Mr O'Rourke told Parliament that the bill was about certainty for future retirees, fiscal responsibility and, most of all, fairness.

"Fairness to retirees who have lived here all their lives, to immigrants and to returning expatriates and to present and future taxpayers.

"No one has all the answers to the many problems with the current system and of course its costs, so this bill is entirely negotiable."

National's David Bennett said the legislation was a disgrace and typical of New Zealand First.

"This bill treats people born outside of New Zealand differently from other New Zealanders, that is the disgust of this bill.

"They are saying that if you are not born in New Zealand, you are not a true New Zealander - that is what this bill says and I say to that party, half of them probably weren't even born in New Zealand."

Labour's Grant Robertson said there was only one disgraceful person in the House, and that was Mr Bennett.

"On this side of the house we might not support every bit of this piece of legislation, but at least Denis O'Rourke has come to this house to address the issue of how we make superannuation sustainable in this country, and all you've got to offer is insults and nonsense. Mr Bennett, you are a disgrace."

Green Party MP Jan Logie voiced her objections to the bill in a far more measured tone.

"I understand while not the tone or the detail of the bill [intends it] it would be possible to interpret some of the provisions in this as borderline racist."

Labour and the Greens said they agreed with only parts of the bill, but were willing to support it to select committee so a debate could be had about the future affordability of superannuation.

However, the legislation narrowly failed by 61 to 60 when National, ACT and United Future voted against it.