Three police officers in California were cleared of any wrongdoing after they fired at a mass shooting suspect who was on a killing spree, Santa Clara County District Attorney's Office said Tuesday.

Santino Legan, 19, walked into the Gilroy Garlic Festival on July 28 armed with a loaded AK-47 assault rifle and opened fire indiscriminately at the crowd, killing 3 persons and injuring at least 17. The cops, identified as Detective Cryar, Officer Basuino and Officer Del Moral, confronted Legan within a minute but he pointed his gun at them too. The three officers fired multiple shots back at Legan, striking him in the chest, back, hands, and legs. Legan shot himself to death immediately after, Santa Clara County District Attorney’s Office said in a statement.

Legan was said to have fired at least 36 rounds of ammunition prior to his death. The dead included a 13-year-old girl, a 25-year-old man, and a 6-year-old boy.

“If we didn’t take the action that we took there could be a lot of dead people,” Detective Cryar, a military veteran, told investigators when asked for an explanation.

Deputy District Attorney Rob Baker said their actions were “unquestionably lawful” as they had “undoubtedly saved lives and prevented further bloodshed.” He also lauded them for entering the line of fire to carry out their responsibility.

The shooting was still being investigated by the FBI and the Gilroy Police.

Several bullets are pictured on a table. Pixabay