On the final count, 56.4 percent of people had rejected the proposition that New Caledonia become independent, in a clear but smaller-than-expected victory for loyalists to the mainland.
As the results came in, French President Emmanuel Macron spoke of his "immense pride" that the Pacific islanders had voted to remain part of the French Republic.
"The majority of Caledonians have chosen France: it's a sign of confidence in the French republic, in its future and its values," Macron said in a televised address from the Élysée Palace.
The landmark referendum had been promised as part of a deal signed two decades ago to end a violent campaign by separatists from the indigenous Kanak people.
It was seen as a test of the appeal of remaining part of France for such far-flung territories, which are heavily dependent on state handouts but where many feel overlooked by Paris.
Located some 18,000 kilometres (11,000 miles) 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 strategic foothold for France in the Pacific.
Some 175,000 people were eligible to vote, with officials reporting turnout at over 80%.
Some polling stations in Noumea, the capital, closed about an hour late because they had large lines of people still waiting to vote at the planned closing time.
A previous referendum in 1987 was undermined after Kanak's boycotted the vote claiming the terms of voter eligibility were unfair. This time round only residents of 20 years or longer can vote, excluding many white European migrants with a weak connection to the territory.
The village of Farino was the first to declare, voting by a margin of 9 to 1 against independence, with nearly 95% of registered voters casting ballots.
But support for independence from France was much stronger in areas with a large indigenous population, with the vote “playing out largely along ethnic lines”, said FRANCE 24’s correspondent Jack Hewson.
In his televised address, Macron said his government would be meeting with Caledonian leaders in the coming weeks, with Prime Minister Édouard Philippe and Overseas Minister Annick Girardin due in Noumea on Monday.
There were fears the referendum could inflame tensions between Kanaks, who tend to favour independence, and the white population, which boiled over into deadly violence in the 1980s.
The quasi-civil war claimed more than 70 lives. It led to the 1998 Noumea Accord which paved the way for the steady devolution of powers as well as Sunday's referendum.
Under the 1998 deal, two further referendums on independence can still be held before 2022.