A school was forced to shut to most students after travellers set up camp in the car park.
Shenley Academy in Birmingham said it was closed to all Year 7, 8, 9 and 10 pupils after travellers ignored an eviction notice issued on Saturday.
The group which officers said included 20 caravans, a horse and dogs, has since left the site.
West Midlands Police said it had helped evict the group after the city council served an immediate eviction demand.
The academy remained open to pupils in Years 11, 12 and 13 who were told to avoid using the main entrance and were escorted on to the site by police and staff.
School principal Lucy Monk said of the partial closure: "I recognise that this situation is detrimental to the education of our students, and it is certainly not a decision which has been taken lightly."
Mrs Monk said in a statement later, the travellers had left the site and all students could return to school on Tuesday.
They left behind a horse, which was tied to the school fence.
The school is looking after it at the moment but it will go to the RSPCA if it is not reclaimed.
Margaret, from the group of travellers, told the BBC more traveller sites were needed.
"If there were more sites this wouldn't happen, she said. "There's going to be an awful lot more of this up until summer until the kids break up from school."
"There's no uproar about these children [from travelling community] not going to school or not having a home for themselves to live in," she added.
However, local police sergeant Dave Cotter said the travellers' behaviour was "totally unacceptable" and had caused huge disruption.
"The group ignored a notice to leave, which gave them 24 hours to move on, and in the end we were left with no option but to force them to leave the school grounds," he said.
Meanwhile, the travellers are believed to have moved on to a site in Kings Norton.
A resident told the BBC they had been evicted from the same place two weeks ago.