Suspected sham marriages have been targeted
Law Lords have ruled the home secretary cannot use controversial powers to stop sham marriages as they discriminate against foreigners in the UK.
They said the Home Office had interfered in an "arbitrary and unjust" way in the rights of 15,000 people.
Ministers said the rules were vital to tackle illegal immigration scams - but conceded they will need to be reformed.
The measures were brought in after registrars complained they they had no way of stopping bogus marriage rackets.
But many foreign nationals said they were being treated unfairly, and that the scheme was unnecessary, slow and bureaucratic.
They also said it was expensive - the regulations meant they had to pay up to £600 in fees to get permission to marry.
The controversial Home Office powers on marriages were introduced in February 2005.
The rules meant 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 the powers were challenged in April 2006 when three couples alleged their human rights had been breached.
In the first case the home secretary refused permission to marry to Mahmoud Baiai, 37, an Algerian illegal immigrant, and Izabella Trzcinska, 28, from Poland, who was in the UK legally.
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.
All three were later given permission to marry.
In his ruling against the Home Office, Lord Bingham said immigration rules, as well as the right to respect for family life under the European Convention, gave protection to some migrants who marry in the UK - even if they had limited or no leave to enter or stay.
He added that the Immigration Directorate had issued instructions, without clear parliamentary approval, to deny permission to marry under certain circumstances.
"The vice of the scheme is that none of these conditions, although of course relevant to immigration status, has any relevance to the genuineness of a proposed marriage," he said.
The ruling was welcomed by some campaigners - the chief executive of the Joint Council for the Welfare of Immigrants, Habib Rahman, said the government's policy was now in "tatters".
He added: "It's a great day for human rights, for justice and for migrant communities... The government will have to go back to the drawing board."
Solicitor Amit Sachdev, who represented three of the claimants in the case, described the marriage legislation as "draconian... misconceived and ill thought-out".
The scale of sham marriages is unknown, 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.
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.