By Dominic Casciani
BBC News home affairs
Controversial immigration rules aimed at stopping sham marriages are unlawful, says the Court of Appeal.
Arrests: Suspected sham marriage targeted
Judges said the law breached the fundamental rights of immigrants subjected to the vetting.
Last year three couples argued at the High Court that the home secretary had discriminated against them.
Three senior judges have now agreed, saying ministers failed to find out if those marrying were genuinely in love or part of an immigration scam.
The Home Office said it was "disappointed" the court had dismissed its appeal.
It said the scheme has been "instrumental in tackling the issue of sham marriages" which were an "abuse" of immigration rules, adding it would study the judgment before deciding whether to appeal to the House of Lords.
In February 2005, the Home Office introduced rules meaning people who were not legally permanently settled in the UK were obliged to seek special permission to marry, irrespective of the status of their partner.
But in April 2006 three couples alleged their human rights had been breached.
In the first case the home secretary refused permission to marry to Mahmoud Baiai, an Algerian illegal immigrant, and Izabella Trzcinska, from Poland.
The two other cases related to asylum seekers, including one individual who had been told to leave the country but wanted to marry someone already given protection as a refugee. Both the asylum-related couples were later given permission to marry - but Mr Baiai and Ms Trzcinska were not.
In the judgement, Lord Justice Buxton said the home secretary could only interfere in the right to marry in cases that involved, or were very likely to involve, sham marriages with the object of gaining right to live in Britain.
"A scheme to achieve that end must either properly investigate individual cases, or at least show that if has come close to isolating cases that very likely fall into the target category. The scheme in issue in this case does not pass that test."
Amit Sachdev, lawyer for two of the couples, said the government had respected neither his clients' rights nor an earlier court ruling in their favour.
"This law was a knee-jerk reaction based on speculation and conjecture rather than evidence," said Mr Sachdev. "Even the House of Lords complained the Act had not received proper scrutiny."
SUSPECT MARRIAGES REPORTED BY REGISTRARS
Note: 2005 figures incomplete; new law came into force in February. Source: Home Office
In the case, judges heard applicants to the scheme had to pay the Home Office £135 and that their proposed marriage could only be dealt with in one of 76 special register offices.
However, the law did not apply to couples who were marrying in the Church of England, even if they fitted the same background as those typically suspected of sham marriages.
Campaigners said the law was discriminatory because it effectively labelled some immigrants as fraudsters without assessing the merits of their case.
The High Court ruled in 2006 the law was incompatible with human rights on grounds of nationality and religion, particularly because those marrying in the Church of England were not subject to the same sort of scrutiny as couples from other faith backgrounds.
Lawyers for the home secretary had argued that the exemption was valid because there was no evidence of any sham marriage rackets attempting to use Anglican ceremonies.
Nobody knows the scale of sham marriages, although senior registrars suggested that before the new legislation there could have been at least 10,000 a year.
Registrars at Brent Council in north London suggested in 2005 that a fifth of all marriages there were bogus, with officials able to spot couples who barely knew each other.
One 2005 case saw 25 people jailed for a sham marriage network stretching from London to Leicester.
According to Home Office figures, since the new checks were introduced the number of suspicious marriage reports received from registrars fell from 3,740 in 2004 to fewer than 300 by the end of May 2005.
Between January and August 2006, there were only 149 such reports, it said.