A legal observer who was kettled during a demonstration against government cuts has won a high court declaration that police acted unlawfully when they filmed her and made her hand over personal information before she was released.

Rights groups welcomed the judgment and urged the police to ensure compliance with it.

Susannah Mengehsa, a volunteer barrister with the Bar Pro Bono Unit, which helps people get free legal assistance, was on a public sector trade unions march in the West End of London in November 2011 when she was caught within a police operation to contain about 100 people.

Before being released from the kettle in Panton Street, she was escorted to an area where she was required to give her name, address and date of birth. She was also searched, photographed and filmed by police in a process she described as oppressive, aggressive and intimidating.

Having ordered the containment after observing trespass and damage taking place in Panton House, police justified their actions with respect to Mengehsa and the other people who were kettled on the grounds that it would help any subsequent post-incident investigation to identify people involved in criminal activity.

Lord Justice Moses and Mr Justice Wyn Williams, sitting at the Royal Courts of Justice on the Strand, ruled that the demonstrators and legal observers had been lawfully contained but that officers had exceeded their powers in the conditions they set in order for people to be allowed to leave.

"It was not lawful for the police to maintain the containment for the purposes of obtaining identification, whether by questioning or by filming," said Moses. "It follows that it was not lawful to require identification to be given and submission to filming as the price for release."

He added: "The absence of any statutory power to obtain identification in the circumstances in this case establishes conclusively the unlawfulness of the police action in requiring the claimant to be filmed and give her name and address and date of birth before she was released from containment."

He ordered the deletion of the film and her personal details. Menghesa's solicitor Fiona McNelis described the ruling as "a huge step forward for protesters".

Val Swain, director of Netpol, the police monitoring network Mengehsa is an activist for, said the practice she had challenged had become routine in the UK, enabling forces to obtain the personal data of thousands of people taking part in lawful protest and retain it for many years. "We hope now that these excessive police practices will finally be curbed," she said.

James Welch, legal director for Liberty, said: "It shouldn't have needed a court to tell the police they can't require personal details and compulsory filming before releasing people from a kettle. Any law student could have worked that out."

Nick Pickles, director of the privacy and civil liberties campaign group Big Brother Watch, said: "The question must now be what action will be taken by the Metropolitan police to ensure this kind of issue does not continue to arise and this must involve meaningful sanctions for officers who act unlawfully."

Pickles's comments were echoed by the London assembly member Jenny Jones, who said: "The [Met] commissioner needs to make clear to his officers that this practice is not acceptable and to ensure that no officer behaves in this unlawful manner again."

A Met police spokesman said the force would give the judgement "our full consideration and take forward anything learned".