Cameron also insisted that any solution to the recent row between Spain and Britain over the outpost would be achieved through diplomacy, not rhetoric.
"The British government wholeheartedly supports your right to determine your political future," the prime minister said in a video message to be screened as part of Gibraltar's National Day.
"We will never agree to any transfer of sovereignty — or even start a process of negotiation of sovereignty — without your consent.
"Gibraltar has been British for 300 years. Let's keep it that way," he urged.
A dispute has broken out between London and Madrid in recent weeks after Spain introduced stringent border checks which led to waits of several hours for motorists trying to enter the tiny territory.
Gibraltar has accused Madrid of imposing the checks in retaliation for its decision to drop concrete blocks into the sea in July to create an artificial reef to boost fish stocks — blocking Spanish fishing boats from entering the area.
Cameron praised the people of Gibraltar for facing "the pressures of recent months with enormous dignity" and said their relationship with Britain was "solid, sure and enduring".
He vowed to seek a resolution to the dispute "through dialogue and not in unacceptable border delays, or other actions or rhetoric."
Gibraltar's national day marks the anniversary of the territory's first referendum on sovereignty in 1967.
Asked to decide whether they wished to remain with the UK or join Spain, 99.64 percent of the voters cast their ballots for UK sovereignty.
Only 44 of the 12,672 votes cast were in favour of Spanish sovereignty for The Rock.
This year's national day also coincides with the 300th anniversary of the signing of the Utrecht Treaty in which the Kingdom of Castile ceded to "the Crown of Great Britain the full and entire propriety of the town and castle of Gibraltar" forever.
That treaty did not specify who controls the waters around Gibraltar, a fact which has been a bone of contention between the UK and Spain ever since.