Cameron welcomed Fabian Picardo for talks at his Downing Street office in London on Friday, with the row on the border still rumbling on.
"Britain will always stand up for Gibraltar. We will always stand up for the interests of the people who live in Gibraltar," Cameron told Picardo.
"It is something that matters to us very deeply."
The chief minister thanked him, saying: "The people of Gibraltar know they have a friend in David Cameron and a friend in (Foreign Secretary) William Hague.
"That Gibraltar continues to be on your mind means a lot to us."
A dispute has broken out between London and Madrid in recent weeks over the British outpost, after Spain introduced stringent border checks which have 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.
A Downing Street spokeswoman said: "The meeting reaffirmed the existing strong and historic bonds between the UK and Gibraltar and the prime minister repeated his commitment to stand shoulder to shoulder with the people of Gibraltar.
"They discussed the unacceptable delays at the Spanish/Gibraltar border and agreed that these are damaging to the people and economies of Gibraltar and
"They agreed that efforts should remain concentrated on finding a diplomatic solution, in line with the foreign secretary's proposals last year for ad hoc dialogue."
Spain ceded Gibraltar to Britain in perpetuity in 1713 but has long argued that it should be returned to Spanish sovereignty. London says it will not do so against the wishes of Gibraltarians, who are staunchly pro-British.
Gibraltar governs its own affairs, except foreign affairs and defence.
About 10,000 Spaniards cross the frontier each day to work in the self-governing British overseas territory which measures just 6.8 square kilometres (2.6 square miles) and is home to about 30,000 people.