Judges ruled that allowing the injunction would have significant consequences for the government's duty to house asylum seekers and could encourage other councils to seek similar bans.
Labour grandee Lord Falconer urged his party to take decisive action on the migrant crisis, supporting the government's court victory but stressing the need to close asylum hotels.
Epping Forest District Council, which initially secured the injunction, is considering an appeal to the Supreme Court, while protesters have vowed to hold regular demonstrations.
The ruling highlights the ongoing challenge of housing asylum seekers, with over 32,000 individuals accommodated in UK hotels by the end of June.