It was one of the worst-case scenarios for a school shooting: a yard full of children playing with a rampaging gunman just minutes away.

At Rancho Tehama Elementary School in Northern California last week, children were quickly hustled indoors to locked rooms as Kevin Janson Neal drew closer.

One student was shot, but nobody died. And that, authorities say, is stunning.

“I had a student injured badly and I’m heartbroken about that, but there’s cause for hope,” said Corning Union Elementary School District Supt. Richard Fitzpatrick. “If we can lock down and we can eliminate ourselves as an apparent target, our kids can go home at the end.”

Rancho Tehama Elementary is a small, rural school — fewer than 100 students, nine employees and four classrooms, Fitzpatrick said in a televised news conference last week in which he recounted the school shooting based on surveillance videos he watched, conversations with school staff and his own recollection. He was on the phone with school staff during the shooting.

Between 7:50 and 7:53 a.m. Tuesday, the school secretary and other staff members heard a gunshot nearby. Then they heard two more.

“The first shot was loud, it was close,” Fitzpatrick said. “But the second two came in close succession. ‘Pop. Pop.’ ”

That’s all the secretary needed to announce a lockdown. The staff quickly went into the yard and began corralling students into their classrooms and ushering parents into the office.

About two-thirds of the lockdown was complete when the shooter rammed a gate at the north end of the campus with a white pickup truck, breaking through the school fence.

The school’s head custodian poked his head around the building and made eye contact with the shooter, who fired at him, Fitzpatrick said.

“The shooter was struggling with his weapon at this time,” Fitzpatrick said. The gun appeared to be jammed, and he was having trouble loading ammunition, Fitzpatrick said.

The superintendent believes that interaction gave staff a few more seconds to get children into classrooms, completing the lockdown.

Surveillance video shows that eight to 10 seconds after every room was secured, the shooter entered the quad, Fitzpatrick said.

“The school secretary recognizing the threat — that quickly made all the difference between 100 kids being around today and dozens being shot or killed,” he said. “That amount of seconds was critical.”

Neal ran into the quad shooting, a “horrific” look on his face, Fitzpatrick said. He shot at the building to his left, then at the office. His bullets shattered glass and pierced wood walls and bookshelves.

One child, identified by family members as 6-year-old Alejandro Hernandez, was shot in the chest and foot in the K-1 classroom. The teacher and aide immediately started attending to him, applying direct pressure to the wounds, Fitzpatrick said. Alejandro is expected to survive.

In between shooting, the gunman tried to get into classrooms and the main office, but was unable to gain entry. He checked the bathroom, which was open but empty.

Then he walked to the school’s field, loaded a magazine and fired outward into a fenced, forested area outside of the school.

“It looked as if that was done in frustration,” Fitzpatrick said.

About six minutes after he had crashed through the school’s gate, the shooter drove away.

There are two options when students are outside during an active shooter situation: “You either bring them in or run,” said Dennis Lewis, co-founder of the school safety consulting and training company Edu-Safe.

“Staff have to make a split-second decision based on what they know, and they often know very little,” Lewis said. In this case, it appears a well-trained staff “combined with a little bit of luck” came together to save these lives, he said.

A small school population combined with the shooter’s problems with his weapon may also have helped the staff get into classrooms faster, he said.

School staff members have practiced drills and executed lockdowns before, so even though they had never had an active shooter on campus, they knew what to do, Fitzpatrick said.

“The lockdown procedure was implemented flawlessly,” he said. “The reason that we have a situation where I have one student injured on campus and nothing worse happening on campus is because of the heroic actions of all members of my school staff.”

At an earlier news conference after the shooting, Fitzpatrick said the wounded student was hiding under a desk.

During an active shooter situation, students should be low to the ground and out of sight, but under their own desks may not be the best hiding place, Lewis said. Without knowing where in the classroom the student was hiding or how the school was configured, though, he said he could not determine whether the students at Rancho Tehama were in the safest spot.

Typically, students should not be spread out and should be in the back corner of a classroom farthest from the entryway, he said.

Regardless, he said, the secretary who called for a lockdown, without waiting for law enforcement direction, saved dozens of lives.

“I often say that in these school shootings, seconds matter,” Lewis said. “There’s an example where seconds mattered.”