On the final count, 56.4 per cent of people rejected the proposition that New Caledonia become independent.
Islanders on the French Pacific territory of New Caledonia rejected independence on Sunday in a referendum, but the results showed weaker-than-expected support for Paris in the resource-rich and strategic outpost.
Some 18,000 kilometres from the French mainland, New Caledonia is home to a quarter of the world's known supplies of nickel - a vital electronics component - and is a foothold for France in the Pacific where China is gaining influence.
On the final count, 56.4 per cent of people rejected the proposition that New Caledonia become independent. Turnout was high at 80.63 per cent.
President Emmanuel Macron expressed his "immense pride that we have taken this historic step together" in an address to the nation, adding it was "a sign of confidence in the French republic, in its future and its values."
But the winning margin on New Caledonia, sometimes referred to in France as "the pebble", might cause some concern in Paris, as well Australia which has been alarmed by Beijing's designs in the Pacific and its investment in island nations.
Polls beforehand had forecast an emphatic 63-75 per cent of New Caledonians would vote "no" when asked if the archipelago should "attain full sovereignty and become independent."
Under a 1998 deal called the Noumea Accord to devolve powers to the territory, two further votes on independence can be held by 2022 -- a right independence leaders look set to invoke.
"We're a short step away from victory and there are still two votes to come," Alosio Sako, head of the separatist movement FLNKS, said after the results were announced.
Balancing China in the Pacific?
Macron had largely stayed clear of the campaign in New Caledonia, but during a visit to Noumea in May he declared "France would be less beautiful" without the territory.
As well as being home to French troops and being a source of nickel, the territory gives France a large, exclusive economic zone in the Pacific and rich fishing resources.
The 40-year-old French leader has also raised concerns over increasing Chinese influence in the Pacific, where Beijing has invested heavily in Vanuatu, a territory which broke from France and Britain in 1980.
Accusing the US of "turning its back on the region in recent months", Macron said China was "building its hegemony step by step" in the region -- suggesting an independent New Caledonia could be Beijing's next target.
During visits to New Delhi and Canberra since taking power last year, Macron has talked up France's Pacific presence to propose an axis of democratic Asian maritime powers that would include India and Australia.
There were fears that the referendum in New Caledonia could inflame tensions between indigenous Kanak people, who tend to favour independence, and the white population which has settled since France annexed the islands in 1853.
Several cars were burned and a couple of incidents of stone-throwing were reported late Sunday, local authorities said, but the vote was otherwise peaceful.
Tensions in New Caledonia boiled over into ethnic strife in the 1980s which claimed more than 70 lives.
That led to the 1998 Noumea Accord which paved the way for a steady devolution of powers, as well as Sunday's referendum and possibly two others before 2022.
In recent years, France has faced protests and calls for independence in several of its overseas territories, which are a legacy of the country's colonial history and are sometimes dubbed "the confetti of the French empire".
French Guiana in South America and the Indian Ocean archipelago of Mayotte have been rocked by major protests over living standards and perceived neglect.
Closer to home, the Paris government also faces renewed calls for independence from nationalists on the Mediterranean island of Corsica, which have been rebuffed by Macron.
Separatists had urged Kanak voters to choose self-determination for Kanaky, their name for New Caledonia, and throw off the shackles of the "colonial" authorities in Paris.
The Kanak community is economically disadvantaged compared with the white population and plagued by high school dropout rates, chronic unemployment and poor housing conditions.
But indigenous people make up less than 50 per cent of the electorate and some Kanaks back staying part of France, not least due to the 1.3 billion euros the French state hands to the islands every year.
Going it alone, "I'm not sure we have all the assets we'd need to succeed," said Marc Gnipate, a 62-year-old pensioner.