New Caledonia has voted against independence from France, with 56.4 percent choosing the status quo.
More than 174,000 voters were eligible to vote in the first such referendum in more than 30 years.
The result has defied predictions of a landslide as the anti-independence camp hoped for an overwhelming victory to bury the Kanaks' aspirations for a new country once and for all.
The pro-independence side has taken heart from making inroads in the mainly European Noumea area and is determined to invoke the Noumea Accord which allows for another referendum in two years.
Interest has been unprecedented, with turnout at 80 percent and in some electorates soaring to 95 percent.
The anti-independence rivals regret the push for another vote but are split on how to proceed.
Some want to change the French constitution to thwart any further such referendums while others say there has to be a dialogue.
Complex negotiations await all parties and they will begin this morning once the French prime minister has arrived in New Caledonia.
'Do you want New Caledonia to accede to full sovereignty and become independent?'
That was the question put to voters as they had decide whether to end New Caledonia's status as a colony of France.
The vote was the culmination of a peaceful 30-year decolonisation process which had seen a phased and irreversible transfer of a range of powers from France to enhance New Caledonia's autonomy.
What is still left with France, and was voted on, is control over defence, policing, the judiciary, monetary policy and foreign affairs.
Opting for independence would have also allowed New Caledonia to join the United Nations like its four Melanesian neighbours - Vanuatu, Papua New Guinea, Solomon Islands and Fiji.
The electoral roll, which has been the subject of prolonged controversy, is made up of indigenous Kanaks and includes only those non-Kanaks who have lived in New Caledonia continuously since 1994.
These restrictions were negotiated and put in place to take into account decades of massive inward migration which have rendered the Kanaks a minority in their own country.
For the vote, there were comprehensive preparations, with people being encouraged to vote in large numbers to give the result as much legitimacy as possible.
Some towns in the north of the main island put on free buses to take voters in Noumea to and from polling stations.
Defying these efforts was the small Labour Party, which advised its supporters to shun the referendum and to 'go fishing' instead.
Although the campaign was peaceful, there is nervousness about the aftermath.
Some people spoken to said there might be trouble but there is no specific scenario of what could happen and where.
However, for Antoine Thale, a young Kanak lining up to be among the first voters at the Noumea Town Hall, there was nothing to worry about.
To provide additional security, 350 extra French riot police have been in New Caledonia since the middle of October.
For the weekend, there was a ban on the sale of alcohol and it was explicitly forbidden to carry arms or transport ammunition until tomorrow.
Noumea dropped Sunday's planned cruise ship visits purportedly as not to interfere with polling activities.
More than 200 magistrates and senior officials were flown in from France to help supervise the poll.
Monitors from the Pacific Islands Forum were present as were observers from the United Nations, which has been keeping an eye on New Caledonia since it was returned to its decolonisation list in 1986.
Five hours after polls closed, President Emmanuel Macron was due to give a televised address.
During his visit to New Caledonia in May, he declined to take sides to the dismay of those who wanted the territory to remain French.
However, he said "France would not be the same without New Caledonia", while restating his wish to retain New Caledonia as a key component of the 'Indo-Pacific axis' to contain China.
The campaign leading up to the vote, yielded few headlines in France but jumped to the top of the news agenda once the vote was imminent.
Polls in France showed many people were not interested nor aware of what was at stake, while a France TV poll found that a majority of those questioned considered independence for New Caledonia to be a "good or very good thing".