Referendum result
Yes: 187 votes (1.03%)
No: 17,900 (98.97%)
Turnout: 18,176 (87.9%)
Almost 99% of voters said No to the question: "Do you approve of the principle that Britain and Spain should share sovereignty over Gibraltar?"
Gibraltar's Chief Minister, Peter Caruana, who called the referendum, said he hoped the result would help to convince the UK Government to end talks with Spain on the matter.
Although Madrid and London have been holding negotiations about the status of the Rock, they have not made any final agreement about the colony's future.
Both Spain and the UK said they would not recognise the referendum.
'No surprise'
"Fellow Gibraltarians, today we have sent a clear message to the world," Mr Caruana said in his victory speech.
"One, that this is our homeland; two, that we are a people with political rights that we will not give up; and three, that those rights include the right to freely direct our own future and we will certainly not give that up."
Britain's Europe Minister Dennis MacShane said the result came as no surprise.
"We have to reflect on last night, reflect on the last year and try to take this forward," he said on BBC radio.
He added: "It's the young people of the Rock that we have to be concerned about... I just want to ensure that the Union Jack flies over Gibraltar but that that part of Europe starts to function normally."
He emphasised the UK Government's commitment not to change Gibraltar's status without the consent of the people in a referendum.
There has been little official Spanish reaction to the referendum so far, although deputy premier Mariano Rajoy, speaking on Catalan radio, declared it ''illegal".
"What matters to us... is that the talks we are holding with the United Kingdom... can continue in future and reach an agreement that satisfies all of us," Mr Rajoy said.
However, BBC Europe correspondent Tim Franks says there has not been much progress in these talks over the summer and that the British Government will find it difficult to write off the result because it is so emphatic.
European thorn
Just 187 people - 1.03% of voters - voted in support of an agreement with Spain. Turnout was 87.9%, or 18,176 voters.
The result repeats the outcome of a referendum 35 years ago in which Gibraltarians voted overwhelmingly to remain British.
Many Gibraltarians complain that the British Government is trying to "sell them down the river" by doing a deal with Spain to smooth over an issue which has long been a thorn in the side of European relations.
In July, UK Foreign Secretary Jack Straw told parliament that Britain and Spain were in "broad agreement" about the principles of sharing sovereignty but that there were outstanding issues that remained to be resolved.
Spain is believed to regard shared sovereignty as a temporary, rather than a permanent, solution and is reluctant to give Gibraltar the final say.