Image copyright EPA Image caption Mariano Rajoy says Gibraltar belongs to Spain

Spanish prime minister Mariano Rajoy is unhappy about David Cameron's EU referendum campaign visit to Gibraltar.

Mr Cameron cancelled a planned rally in Gibraltar following news that MP Jo Cox had been attacked in her constituency.

All activity has been suspended by both the Leave and Remain campaigns.

Speaking earlier, Mr Rajoy that although he wants Britain to remain in the EU Mr Cameron should not visit Gibraltar to make the case.

He told Spanish National Radio: "The government does not like Mr Cameron travelling to Gibraltar."

He added that "what is being debated is that the United Kingdom remain in the EU or leave the EU and the campaign should happen in the United Kingdom and not in Gibraltar".

Conservative Leave campaigner Liam Fox, who is also on a visit to Gibraltar, speaking before the attack on the MP happened, said Mr Cameron "must make clear that whatever the referendum result the UK will fully back the sovereignty and security of Gibraltar - the message must be completely unequivocal".

He added: "Gibraltar's successful economy is based on tourism, shipping, financial services and online games. All would benefit from a free market without the supremacy of EU law and the regulations imposed by Brussels."

Media playback is unsupported on your device Media caption Gavin Lee reports from Gibraltar, where neighbouring Spain will have an impact in the way residents there vote in the EU referendum

Gibraltar is a self-governing British overseas territory so if the UK leaves the EU, Gibraltar - which is 2.2 square miles and stands at the mouth of the Mediterranean bordering Spain - leaves too.

Opinion polls suggest the 23,000 UK citizens entitled to take part in the referendum in Gibraltar will vote to remain in the EU, amid concerns its border with Spain would be closed if Britain left, something Vote Leave say could still happen if Britain stayed in the EU.

Currently, Gibraltar is covered by EU rules governing the single market, specifically the free movement of people.

In March, Spain's foreign minister Jose Manuel Garcia-Margallo told Spanish radio Spain would demand control of Gibraltar the "very next day" after a British exit from the EU, according to the Gibraltar Chronicle.

In May, Gibraltar's first minister Fabian Picardo told Sky News: "If Gibraltar wanted to have access to the single market and the rights we enjoy today of free movement, we would have to once again consider joint sovereignty with Spain, which no one in Gibraltar is prepared to consider."

Forty-one-year-old Labour MP Jo Cox died after being shot and stabbed in an attack in her constituency in Birstall, West Yorkshire.