A 12-year-old US boy accused of walking into a classroom with a handgun, pointing it at his teacher and pulling the trigger is in custody on a charge of attempted murder.

The gun did not go off as the safety catch was on. The teacher then managed to talk him down and disarm him, court papers say.

The incident happened at a junior high school in Iowa on 31 August.

The school was put on lockdown and police seized the gun.

The boy is alleged to have walked into the classroom at North Scott junior high school in Eldridge with a handgun and ordered everyone to the floor.

He pointed the gun, which had one round in the chamber, at the teacher's face and pulled the trigger, according to the documents.

No-one was harmed during the incident, and the boy's teacher and another staff member were able to take the gun from the boy.

He faces charges of attempted murder, carrying a weapon on school grounds, and assault while displaying a dangerous weapon.

He has been ordered to remain in state custody at a juvenile detention centre for the time being.