The EU's top court on Thursday found Britain at fault for demanding that non-EU citizens with resident permits issued in other member states must obtain a visa before entering the country.
The European Union defends the free movement of people as a fundamental principle that all 28 members must respect but the British government of Prime Minister David Cameron wants to curb immigration, a hugely sensitive issue in the run-up to a May general election.
The European Court of Justice ruled in favour of a Colombian woman who argued she did not need a visa to visit Britain as she had a residence permit from Spain where she lived with her husband who has dual Irish and British nationality.
"Where third-country nationals hold a residence card of a family member of a Union citizen, the United Kingdom cannot make their right of entry subject to the requirement that they must first obtain a visa," the court said.
In 2012, the woman, Helena Patricia McCarthy Rodriguez, and her husband filed suit with the High Court of Justice of England and Wales, saying that the British visa requirement infringed their rights of free movement.
The court then sought an opinion from the ECJ, the EU's highest court, which ruled in favour of the McCarthy family.
It cited a directive on the right of EU citizens and their family members to move and reside freely within the territory of member states.
"The directive on free movement of union citizens does not allow measures which ... preclude family members from entering the territory of a member state without a visa."
However, the ECJ also ruled that member states can "refuse, terminate or withdraw" a right of entry "if there is an abuse of rights or fraud" but only after studying each case individually.