Five teenagers brandishing baseball bats and machetes rampaged through a suburban school Monday and hit a teacher over the head, police said. Eighteen students were treated for minor injuries.

The drama unfolded as hundreds attended an assembly in an outdoor area of Merrylands High School. As the attackers moved in, teachers rushed the students back to class, where they sought refuge behind locked doors, under desks, even in a cupboard.

"I find it very difficult to believe the brazenness of how they entered the school," Police Detective Inspector Jim Stewart said. Such school violence is rare in Australia.

The teens, between the ages of 14 and 16, were arrested and likely would be charged with assault and other crimes, Stewart said.

Police refused to say whether the teens were students at the school. They were still being questioned by police late Monday.

A 43-year-old teacher was treated at a hospital after being hit on the head with a bat when he tried to stop the attackers, and 18 students were treated for cuts from broken glass and other minor injuries, Stewart said.

Two of those students -- a 13-year-old boy and a 14-year-old girl -- were taken to a hospital for further treatment, police said. No one was seriously injured, Stewart said.

Some students reported the gang was armed with two machetes.

"We were having an assembly and a bunch of guys walked in with some machetes and baseball bats and they said they were looking for some kid," an unnamed male student told Ten Network television news.

"Teachers made an announcement; they rushed us all into the class rooms, locked us in," he added.

Another student said children panicked in the classrooms and hid under tables and desks as teachers barricaded doors.

Worried parents rushed to the school as students flooded the airwaves with mobile phone calls and news of the attack was broadcast.

A mother later told Ten that "children were passing out -- fainting because they couldn't breath for panicking."

Stewart said the attackers defied teachers who tried to stop them, but did not challenge police when they arrived, and surrendered their weapons without a struggle. The raid lasted just six minutes, the Education Department in New South Wales state said.

Education Department regional director Tom Urry apologized to the concerned parents who had to wait at the school gates for hours before seeing their children.

"It is a very confusing situation," Urry told Australian Broadcasting Corp. radio.

"Once the police are on site, it's a crime scene, so it's a combination of two departments trying to make sure that when we do release students, we actually release them to people who are their parents," he added.