TEHRAN, Young Journalists Club (YJC) - Toyama prefectural police said the unidentified male suspect was shot by a second policeman and captured after the mid-afternoon attack, when children were still at school. They said his motive was not known.
Teachers put all the children in the school gymnasium for safety after being cautioned by police, principal Yoshiaki Iino told reporters. TV video showed many policemen outside the school.
The 69-year-old security guard, reportedly assigned to the school, was found collapsed outside its entrance.
Public television NHK and other Japanese media said police identified the suspect as 21 years old.
Prefectural police director Tomohiro Yamada apologized in a televised news conference for a gun crime that caused fear in the neighborhood.
"We regret that the police officer had his gun stolen," Yamada said.
Japan, known for its relatively low crime rate, has recently experienced a series of apparently random stabbings.
In a case on a bullet train earlier this month, an attacker fatally stabbed a passenger who tried to stop him after two others were injured. In Shizuoka in central Japan, an 18-year-old man was arrested earlier this week for allegedly slashing a boy on his way home from school.
Shootings are rare. In 2016 there were 25 shooting arrests, including nine involving fatalities, compared to more than 130 knifing cases, according to the National Police Agency.