The use by London police of "kettling" containment tactics during anti-G20 protests in 2009 was unlawful, the High Court ruled on Thursday.
The capital's Metropolitan Police Service said it would appeal the decision, saying the ruling only applied to one instance of containment and not to the measure in general.
Police kept climate-change campaigners within a cordon for hours during demonstrations by anti-capitalist and environmental protestors in London's financial district as the leaders of the G20 nations gathered for an economic summit in April 2009.
The High Court ruled there had been no evidence of any imminent breach of the peace to justify the police's use of the containment measure, the Press Association reported.
The Metropolitan Police told the court they had contained Camp for Climate Action campaigners inside a cordon on Bishopsgate, a street in the City of London, because of fears violent protestors would hijack their more peaceful demonstration.
The judges said police had been "unduly inflexible" in releasing people from the cordon.
Josh Moos, one of two campaigners who brought the case against the force, said he became dehydrated after he was not allowed to leave.
The judges also condemned the way officers armed with batons and riot shields pushed back a large crowd of the campaigners.
They concluded that the containment and the pushing back of the crowd "were not lawful police operations."
The ruling follows criticism over the way the police handled a string of student marches in London last year, which culminated in the worst rioting seen in the capital for years.
Protesters played cat and mouse with officers across the city as they attempted to avoid kettling.
The Metropolitan Police said the judgment related to the individual circumstances of the G20 protest, and not to the use of containment at other events.
"Where necessary we will continue to use containment as a last resort to prevent serious disorder and violence," it said.
"However, we believe that this issue is so important for the police's ability to prevent disorder within protest that we will be appealing [the judgment]"
Follow us on Twitter: