Image copyright AP Image caption Students were not in the school at the time the gun went off

A teacher in the US state of Utah who was legally carrying a gun in her primary school was seriously injured when it accidentally discharged, police have said.

The incident happened in a staff toilet before classes started and no children were in the building, officials said.

The unidentified woman was in a good condition in hospital by the afternoon.

Utah is among a number of states that allow people with permits to carry concealed weapons into primary schools.

A larger number of states leave it up to individual school districts to prohibit firearms on school campuses or allow only teachers and other school staff to carry guns.

Utah also prohibits school officials from asking teachers if they are carrying a firearm.

In Taylorsville, Utah, on Thursday, school district spokesman Ben Horsley told the Associated Press news agency the district required teachers who carry guns at school to keep the weapons with them at all times, including in the toilet.

Mr Horsley said the school would not release details about the teacher at Westbrook Elementary but said she was carrying the gun legally. The district's police were investigating how the gun discharged.

Crisis counsellors were available and a substitute teacher was brought in to supervise the wounded teacher's class, he added.

Police initially thought the gun had discharged directly into her leg but now believe she was injured when the bullet struck a toilet and caused it to explode, sending bullet and porcelain fragments into her lower leg.