A judge said the measures, which were introduced last year, were discriminatory and violated European law, following a challenge brought by campaigners on behalf of two Polish men and a Latvian.
Mrs Justice Lang said the policy broke freedom of movement rules.
The three men were all facing removal because they were found by police and immigration officers sleeping rough.
The government said it was disappointed by the ruling – which applies to people from the EU and European economic area – but would not be appealing.
Mrs Justice Lang said homelessness alone did not meet the legal requirements for deportation, even if accompanied by offences including begging, drinking and nuisance.
“There has been a significant increase in rough sleepers of all nationalities,” she said. “The policy discriminated unlawfully against EEA nationals and rough sleepers.”
The judge also issued “quashing” orders throwing out the Home Office’s policy as published in February and ordered it to pay the claimants’ legal costs.
The Public Interest Law Unit (PILU) at Lambeth Law Centre, which took out the judicial review, said the decision would affect hundreds of people.
It said the Home Office had been carrying out “regular raids” on locations where officials believed they would find European nationals who could be deported.
In her judgement the judge, Mrs Justice Lang, also said the Home Office should not have been using the raids as a chance to verify whether the rough sleepers were abusing their right to reside in another European nation.
PILU said the High Court had shown itself willing to protect the rights of a vulnerable group of workers, adding: “Homelessness cannot humanely be dealt with by detaining or forcibly removing homeless people.”
The judge said the order should be dropped against one of them, a Latvian, Gunars Gureckis, while a Polish man, Mariusz Cielecki, is now expected to appeal against his. The order against another Polish man, Mariusz Perlinski, had already been dropped.
The Home Office had argued the EU’s Free Movement Directive allowed member states to impose restrictions on people in certain situations, including where there were concerns about security, public health, or fraud.
A spokesman said: “We will consider carefully what steps are necessary to ensure we reflect the judgment in future enforcement.”
He added that most of the people removed under the measure had not exercised their rights to residency in the UK when required and were therefore not lawfully in the country.
Mrs Justice Laing urged the Home Secretary to “take stock and re-consider the terms of the proposed revised policy, in the light of advice from her legal advisers”.