Sheriff Spurlock said neither suspect had been on law enforcement’s radar before the shooting and that the motive was unknown.

The sheriff said the injured students were age 15 or older.

Students who were not injured were taken to Northridge Recreation Center in Highlands Ranch, where hundreds of anxious parents gathered to look for their children on Tuesday afternoon.

“I heard a gunshot,” said Makai Dixon, 8, a second grader who had been training for this moment, with active shooter drills and lockdowns, since he was in kindergarten. “I’d never heard it before.”

Makai’s parents said they joined thousands of others in rushing to the school as news blazed through this suburban community.

“We’re more messed up than they are,” Makai’s mother, Rocio, said as they walked to their car.

The shooting at the Highlands Ranch charter school is the latest at an educational institution, rattling communities nationwide because young people have been put in mortal danger in places long considered safe havens. One week earlier, a man with a pistol shot six people on the last day of spring classes at the University of North Carolina at Charlotte, killing two.