The order blocks protesters from gathering outside or near Anderton Park Primary School, from distributing leaflets and from making offensive comments about staff on social media.
However, Mrs Justice Moulder said a judge will reconsider the injunction at a hearing in Birmingham on 10 June.
Protesters, who face arrest if they break the order, will then have the chance to make their case in court.
They could also file an application to discharge the injunction before that date, providing they give the council 48 hours’ notice.
Birmingham City Council said it made an urgent application “in the light of increasing fears for the safety and wellbeing of the staff, children and parents of the school”.
Council leader Ian Ward said: “I’m pleased that common sense has prevailed because children right across Birmingham should be free to attend school safely and without disruption. All our schools must be safe spaces and we will not tolerate the ongoing intimidation of parents, hard-working school staff and local residents.
“This interim injunction has been secured in time for the return to school on Monday [3 June] and now hopefully the pupils will be able to continue their education in peace for the remainder of the summer term. We’ll continue to support the school and its staff and I would urge parents to take this opportunity to engage in constructive dialogue with the school about any concerns they may have.”
Damian Hinds, the education secretary, who has previously called the demonstrations “unacceptable”, welcomed the injunction.
But Tory leadership candidate Esther McVey sparked fury among colleagues when she claimed parents should be able to stop their children learning about LGBT+ relationships in school.
She said she did not agree with the demonstration but added: “I believe parents know best for their children.”
Protesters indicated they intended to go ahead with another demonstration next week.
Additional reporting by Press Association
Join our new commenting forum
Join thought-provoking conversations, follow other Independent readers and see their replies