The officer fell down dazed, and reached for the gun in his hip holster, but the clip fell out.
As the student came at him a second time, the officer grabbed a secondary weapon - a semiautomatic handgun he carried as backup - from his ankle holster and fired one or two rounds, Dyer said. The student reportedly died within a few minutes.
At least five students and a probation officer on campus witnessed the incident directly, but no one else was injured in the shooting, police said.
Dana Vasquez, a 14-year-old freshman, was on her way to gym class when the situation erupted in an outdoor hallway between two buildings.
"I just saw a bat swinging in the air and heard a gunshot and then I just started running," Vasquez said. She was visibly shaken when she left the school holding her mother's arm.
The cause of the attack was not immediately known, and the officer did not know the student, Dyer said. There was no history of prior run-ins between the teen and the officer, who has been assigned to the school by the police department for the last three years, he said.
"The officer was fortunate that he was able to defend himself," the chief said. "This officer had a secondary weapon that very likely could have saved his life."
Six extra district psychologists will be sent to the school to counsel students and staff, said district spokeswoman Susan Bedi.
Police did not immediately release the identities of the officer or student, who was described as a Fresno resident who transferred to the school in January. The teenager was 6 feet tall and 250 pounds - larger than the officer, authorities said.
The officer was released from a local hospital after being treated for a two-inch gash on the right side of his head, police said. He will be placed on administrative leave while the department reviews his conduct, Dyer said.
The campus was locked down for several hours as detectives interviewed witnesses. An automated system called all parents in the district to notify them of the shooting about three hours after it occurred, and parents received a second message stating that all students and staff were safe an hour later.
"The school district obviously is very saddened by this tragedy on campus, however our students on campus are safe," said Ruth Quinto, acting superintendent of Fresno Unified School District. "There certainly will continue to be support provided to all of our students here on the campus and, in particular, any witnesses to this tragedy."
By 2 p.m., students were allowed to leave the campus gates, where they found a crowd of nervous parents and family members waiting.
Ray Mendez, a volunteer at the school, said he was speaking to a remedial English class when he heard a loud popping sound outside the classroom.
"That's went I went down and saw the young man lying there and the officer was bleeding from his head. This was a real shocker. We try to prevent these kind of events at all costs," Mendez said.
Silvia Carrillo, whose daughter is a sophomore at Roosevelt High, said the shooting did not seem justified.
"My son and my brother went to school here too, and nothing like this ever happened. I think this wasn't enough for him to kill the kid," she said.