MPs have voted to put ACT leader David Seymour's End of Life Choice Bill - which would legalise assisted dying in some circumstances - to a public vote.
It was a tight vote, with 63 voting in favour and 57 against.
This means New Zealand First will support it, after promising not to support the legislation further if the decision isn't put to a referendum.
The question put forward by New Zealand First will read: "Do you support the End of Life Choice Act 2017 coming into force?"
National MP Maggie Barry, one of the fiercest critics of the legislation, argued in Parliament on Wednesday that the question is not clear enough.
Labour MP Louisa Wall said in Parliament it was "appalling" and "abhorrent" that New Zealand First would only support the legislation if it was put to a public vote.
The referendum would take place at the 2020 general election, if the legislation passes third reading in November.
Newshub.