The High Court has criticised the way anti-social behaviour laws were used to prosecute a 17-year-old schoolboy.
The boy and his friends were talking peacefully at a south-west London shopping centre when they were told to leave by a policeman, two judges heard.
The police officer made the order because of a persistent problem with anti-social behaviour in the area, though the group was well-behaved.
The boy was convicted for not leaving, but that was overturned by judges.
The two High Court judges said the police officer's direction was "not a proportionate response".
MB, who cannot be named for legal reasons, was convicted at Wimbledon Youth Court last September after being found guilty of contravening the direction. He was sentenced to a 12-month conditional discharge and ordered to pay costs of £50.
But the two senior high court judges said there had been "an illegitimate intrusion into the rights of people to go where they please in public".
Lord Justice May, sitting with Mr Justice Aikens, said the evidence before the youth court was that MB and his group "seemed well-behaved" at Wimbledon train station and the Centre Court shopping centre.
But the beat officer - knowing that there had been a trend for youths from several of the local schools to meet in the vicinity and start fights - made the dispersal direction using powers under the 2003 Anti-Social Behaviour Act.
Provisions of the Act allow the police to clamp down when they have "reasonable grounds" for suspecting that anti-social behaviour could cause members of the public to be "intimidated, harassed, alarmed or distressed".
Overturning the conviction, Lord Justice May warned police officers that it was not enough, save in exceptional circumstances, to rely solely on past experience.
There had to be "some behaviour on the part of the group" at which the direction was aimed to justify the direction being made.
Otherwise, as the MB case illustrated, "it would intrude on the legitimate activities of young people coming from school by a particular route, behaving properly as they do so."
The judge said he had some sympathy for police officers "having to operate what at the margins is difficult legislation".