A No 10 spokesman said it was looking at the “unprecedented step” after the Spanish government failed to lift the extra controls over the weekend.
“Clearly the Prime Minister is disappointed by the failure of Spain to remove the additional border checks this weekend. We are now considering what legal action is open to us,” the spokesman said.
“This would be an unprecedented step so we want to consider it carefully before a making a decision to pursue.”
The move comes amid a worsening diplomatic row over the the construction of an artificial reef by the Gibraltarian authorities which Spain claims will destroy fishing in the area.
Madrid responded by beefing up border controls, leading to lengthy queues, and suggesting that a 50 euro (£43.30) fee could be imposed on every vehicle entering or leaving the British overseas territory through the fenced border with Spain.
Downing Street would not be drawn on what form any legal action would take, but confirmed that it would be done through Europe.
The spokesman said they believed the action by the Spanish – who have long challenged British sovereignty of the Rock – was “politically motivated and totally disproportionate” and therefore illegal under British law.
“If we go down this route, we will certainly press the EU to pursue the case as a matter of urgency,” the spokesman said.
No 10 thought that David Cameron had won an assurance from the Spanish prime minister Mariano Rajoy that the controls would be lifted over the weekend when they spoke last week.
The spokesman said that was still their understanding of the conversation, even though it was challenged by the Spanish.
Earlier, thousands of Royal Navy personnel set sail for a training deployment in the Mediterranean.
The helicopter carrier HMS Illustrious left Portsmouth Naval Base, Hampshire, and will join the navy flagship HMS Bulwark, for the Cougar ’13 operation.
Also sailing tomorrow will be HMS Westminster, a type 23 frigate, which will visit Gibraltar en route.
Other UK ships taking part are another type 23 frigate, HMS Montrose, and six Royal Fleet Auxiliary (RFA) ships. The vessels will be taking part in what defence officials stressed was a long-scheduled deployment in the Mediterranean and the Gulf.
But London mayor Boris Johnson said the deployment should send a clear signal to the Spanish, and he accused Madrid of reverting to the blockade tactics of the Franco era.
“Perhaps it really is a coincidence – as the Foreign Office claims – that we have just sent a fleet of warships to Gibraltar,” he wrote in an article for the Daily Telegraph.
“Maybe it’s just a fluke that HMS Illustrious is about to bristle into view on the southern coast of Spain, complete with thousands of Royal Marines and other elite commando units.
“But I hope not. I hope that one way or another we will shortly prise Spanish hands off the throat of our colony, because what is now taking place is infamous.”
Commodore Paddy McAlpine, Commander UK Task Group, said Cougar ’13 was an opportunity to enhance the Navy’s ability to “operate and project power as a task group at range”.
“In so doing, it will also remind interested domestic and international parties of the enduring utility, employability and interoperability of the Royal Navy,” he said.
Spain may link dispute to Falklands
Reports in the Spanish media suggested that the row could escalate to the United Nations, with Mariano Rajoy’s government receiving support from Argentina.
Spanish foreign minister Jose Garcia-Margallo is expected to propose that both countries present a “united front” over Gibraltar and the Falkland Islands, El Pais reported.
Mr Garcia-Margallo will sound out his Argentinian counterpart, Hector Timerman, during a meeting in Buenos Aires next month as he prepares for a “180-degree turn in policy towards the colony”, the newspaper said.
Argentina is on a two-year term as non-permanent member of the UN’s Security Council and could potentially use its position to put discussions over Gibraltar on the agenda.
The country’s president, Cristina Kirchner, used a meeting of the council this week to renew demands for talks over the sovereignty of the Falklands.
El Pais quoted diplomatic sources as saying that Spain was also considering the possibility of raising the matter of Gibraltar at the UN’s General Assembly or the International Court of Justice at The Hague.
The No 10 spokesman said: “Our position on sovereignty vis-a-vis Gibraltar and the Falkland Islands hasn’t changed and isn’t going to change.”