California Highway Patrol officers close Lake Road at the intersection of East Bellevue Raod near the University of California, Merced, after a man stabbed and wounded four people on the campus before being shot and killed by police on Wednesday, Nov. 4, 2015. Andrew Kuhnakuhn@mercedsunstar.com

California Highway Patrol officers close Lake Road at the intersection of East Bellevue Raod near the University of California, Merced, after a man stabbed and wounded four people on the campus before being shot and killed by police on Wednesday, Nov. 4, 2015. Andrew Kuhnakuhn@mercedsunstar.com

A UC Merced police officer was justified when he shot and killed Faisal Mohammad, the freshman student who stabbed four people during a Nov. 4 attack on campus, the Merced County district attorney announced Monday.

An investigation into the fatal shooting found that the 18-year-old computer science student posed an imminent threat and that Officer Olaf Lopez appropriately used deadly force to stop him, according to a statement from District Attorney Larry D. Morse II.

Mohammad, from Santa Clara, was shot after he stabbed two students, a university staff member and a private contractor during a violent spree that authorities said was fueled by anger at other students. The four victims were wounded and treated at local hospitals. Campus police opened fire on Mohammad after he lunged at them with a large knife, Morse said.

“This horrible event was a tragedy for everyone involved, especially Officer Lopez, who was forced by Mohammad’s aggressive actions to use deadly force,” Morse said.

Never miss a local story.

Sign up today for a free 30 day free trial of unlimited digital access.

“Officer Lopez correctly assessed a potentially life-threatening situation and took the necessary action to protect himself or anyone else from becoming a victim of a person who was clearly intent on inflicting injury or death on innocent people.”

Authorities have said Mohammad made an elaborate plan to attack and kill students on campus because he was angry over having been kicked out of a study group. According to investigators, Mohammad’s plan was thwarted by a construction contractor who heard screams coming from a classroom where the freshman had stabbed a classmate. Mohammad stabbed the contractor before fleeing from the building, then stabbed another student and a university employee.

Campus police were nearby at the Library Building when they were called to the adjacent classroom building. Lopez spotted Mohammad and followed him toward a bridge on Scholar’s Lane, according to the Merced County District Attorney’s Office.

Officer Kevin Warkentin had joined Lopez. With Mohammad standing about 10 feet away, the officers ordered him to put down his knife and to get on the ground, according to Morse’s statement.

“These commands were issued repeatedly by the officers but ignored by Mohammad,” the statement said.

Instead, it said, Mohammad “advanced toward the officers and appeared to lunge toward Lopez with the knife raised about shoulder height. Lopez drew his service weapon and fired one shot at Mohammad. When Mohammad continued to advance toward the officer, he fired a second shot and Mohammad fell to the ground,” it said.

An ambulance was called to the scene and Mohammad subsequently was declared dead by paramedics.

The investigation into the shooting was conducted by Chief Investigator Pat Lunney, who led Merced police as chief for 15 years and served six years as director of the Division of Law Enforcement for the California attorney general’s office.

Lunney found that Lopez’s actions were in line with established law enforcement training and noted that witness statements about the confrontation were consistent.

The FBI is leading the investigation into Mohammad’s attack. Gina Swankie, public affairs specialist for the bureau in Sacramento, said Monday that the investigation was ongoing.