A spokesman for David Cameron stressed he wanted to get the matter resolved by dialogue but refused to rule out tit-for-tat action.
The warning came as the Royal Navy gunboat HMS Westminster arrived at Gibraltar for a scheduled visit ahead of military exercises in the Mediterranean, involving nine other international vessels.
The arrival of the Type 23 frigate came 24 hours after more than 40 commercial Spanish boats staged a protest over a reef that has sparked the row.
From Whitehall's perspective, the row now centres on Spain's retaliatory delays at the border with the British Overseas Territory. Shortly after HMS Westminster arrived in port yesterday, a Spanish patrol boat passed close to the military area of Gibraltar harbour. It sped off when a Gibraltar police launch neared it.
Resident Andrea Jones, 46, described the warship's arrival as "a two-fingered salute towards Spain".
The diplomatic row flared up earlier this month after the Gibraltarian administration began dropping concrete blocks on the sea floor, creating a reef.
Spain claims it was done to disrupt its fishing fleet but Gibraltar says it was to protect local fish stocks.
The spat intensified when Spain introduced additional checks at the border with Gibraltar, suggesting a 50 euro fee, £43, could be imposed on every vehicle entering or leaving the overseas territory. Some people were left waiting up to eight hours to cross the border.
Fabian Picardo, Gibraltar's Chief Minister, has revealed he and his family have received death threats.
Last week, Mr Cameron demanded "urgent" action on the imposition of the extra checks in talks with Jose Manuel Barroso, the European Commission President, to put more diplomatic pressure on the Spanish Government.
Yesterday, Brussels revealed Mr Barroso had agreed to a Commission fact-finding mission to examine the border controls.