Prime Minister David Cameron said Britain would "never agree to any transfer of sovereignty" of Gibraltar without the consent of its residents as the British territory celebrated its national day on Tuesday.

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."