Protests against the teaching of LGBT relationships probably "strayed into harassing, alarming and distressing conduct", a High Court judge said.
A trial is set to go ahead over whether protests can be held outside Anderton Park Primary School in Birmingham.
High Court judge Mr Justice Warby QC quashed an original injunction keeping protesters from the school and imposed a similar order until the trial.
He said some of the protesting had probably "gone beyond lawful limits".
Parents had been gathering at the school gates over concerns children were "too young" to learn about LGBT relationships.
The initial temporary injunction was put in place to prevent protests directly outside the school.
The school said the new injunction had been "widened to include any protests", and head teacher Sarah Hewitt-Clarkson said she felt "very happy" with the latest judgment.
The trial is scheduled to take place at the end of July and last two to three days.
We are absolutely delighted with the judge’s decisions today. The injunction is widened to include any protests, not just about the teaching of equalities. Children, staff, parents & visitors can leave school safely & calmly. Thank you to everyone for all your support.— AndertonParkPrimary (@AndertonPark) June 10, 2019
The protests have been taking place for weeks, with parents saying they are concerned the lessons are not "age appropriate" and they contradict Islam.
The original High Court injunction had been in place since 31 May, banning demos outside the school, which had to close early before half-term due to escalating action.
But protests have continued and, on Friday, parents held their first demonstration since it was brought in, with about 40 people gathering about 100m from the school outside the exclusion zone.
Campaigners were also outside the hearing held at the Priory Law Courts in Birmingham on Monday.
Birmingham City Council lawyers told the hearing the aim of the injunction was not to prevent people expressing their views but to protect pupils, parents and staff from "unacceptable behaviour".
The court also heard that a police investigation was ongoing into an incident in which people who tied ribbons to the gates in support of the school and members of the LGBT community had eggs thrown at them.
But John Randall QC, representing the protesters, said there had been no arrests.
The protests, he said, had been peaceful and it would require a "snowflake sensitivity" to regard them as terrifying or threatening demonstrations.
The judge said: "I find it likely the claimant [city council] will establish at trial some of the protesting has gone beyond lawful limits and strayed into harassing, alarming or distressing conduct, through its persistence, timing and context."
On Sunday, it emerged Roger Godsiff, MP for Hall Green, which covers Anderton Park, will be spoken to by the Labour Party's chief whip after he told protesters "you're right".
Ms Hewitt-Clarkson said Mr Godsiff's comments were "quite discriminatory" and had "created a sense of incredulity" among his constituents.
She said: "We have to tackle prejudice, we have to seek to eliminate discrimination and actually his comments seem to have fuelled discrimination and fuelled prejudice."
Follow BBC West Midlands on Facebook, on Twitter, and sign up for local news updates direct to your phone.