The Spanish government told Britain Monday it planned to keep the border controls on Gibraltar in place, making it clear to London that the measures were "legal, measured and random," a Foreign Ministry spokesman told Efe.
Madrid was responding to a British government announcement that it was weighing possible "legal action" against Spain over the checks imposed on the border with Gibraltar.
The border controls are legal and Spain was forced to implement them because Gibraltar is not part of the Schengen Area, or EU Customs Union, that allows the free movement of people, the Foreign Ministry spokesman said.
Spain's goal is to prevent smuggling in an area where this type of illegal activity is common, the official said.
The free flow of goods does not apply to Gibraltar because the territory is not in the Schengen Area, the Foreign Ministry spokesman said.
Some 6,700 Gibraltarians live and have an address in Spain but do not list it as their tax residence.
Gibraltar, a territory of 5.5 sq. kilometers (2.1 sq. miles) at the entrance to the Mediterranean Sea, has been held by Britain since 1704 and became a British Crown Colony in 1713 under the Treaty of Utrecht.