More than two million people voted in the ballot to decide whether to keep the one featuring the Union flag or replace it with a silver fern.
The current flag has been the national symbol since 1902. It was up against a new design that was selected from more than 10,000 entries submitted by the public.
Those advocating change argued the flag was a relic of the nation’s colonial past and too similar to Australia’s flag.
But the alternative design failed to gain the momentum it needed to win. While many liked it and people across the country began flying it from their homes and businesses, some considered it garish, a design better suited to a beach towel.
The vote had been orchestrated by prime minister John Key, who was an eager proponent of change. But some saw the endeavour as an effort by him to create a legacy. Others were put off by the cost: 26 million New Zealand dollars (£12m).
In the end, the vote represented a rare political defeat for Key, who has won three straight elections and led the country for eight years.
“Naturally I’m a little bit disappointed the flag didn’t change tonight,” he said.
But he said that every schoolchild had become involved in the debate, which had been good for the nation. He said he was proud to see so many flags flying over recent weeks and would now support the current flag even though it wasn’t his first choice.
Organisers said deciding the issue by popular vote represented a world first, with other countries changing flags by revolution, decree or legislation.
John Burrows, a law professor who led a panel which chose a shortlist of alternative flag designs, said the process had been challenging from the start. He said one thing they learned was that everyone has different tastes and there’s no such thing as a perfect flag.
Opposition leader Andrew Little said the next time the flag issue will be discussed will likely be after the Queen dies, as part of broader debate about the nation’s constitution, including whether it should become a republic.