Musselburgh Grammar School, near Edinburgh, was criticised by government inspectors after they arrived for a surprise inspection earlier this year.
The report said: "The school had experienced a number of serious incidents in which individuals and groups, including excluded and former pupils, had been involved in threatening or violent behaviour to pupils and staff in and around the school.
"One such incident, for example, involved a fight between rival groups in the entrance area of the school."
In a questionnaire given to pupils by the inspectors, one third of those who responded said they were concerned about their safety, and said bullying was not dealt properly with.
The report also said: "A majority of those responding to the questionnaire did not feel that behaviour in classes, corridors and in the playground was good."
Some staff at the 1,000-pupil school found it difficult to deal with a small number of pupils with behavioural problems, the report said.
It concluded: "Overall the ethos was unsatisfactory. The school needed to address major weaknesses in its working atmosphere.
"In particular, the safety and security of pupils and staff, but also behaviour and discipline, needed to be improved as a matter of urgency."
Safety of pupils was also criticised by the report: "There were major weaknesses in safety, security and the overall quality of the accommodation and facilities for care and welfare."Reuse content