An undercover California Highway Patrol (CHP) officer pulled his gun at protesters demonstrating against grand jury decisions not to indict white police officers involved in the deaths of two black men, according to reports. The incident, which took place Wednesday night in Oakland after two plainclothes officers walked into a crowd of 50 protesters and were attacked after being recognized as cops, was described as necessary by authorities on Thursday.

Photos of the CHP officer pointing his gun at protesters were published on social media on Thursday in the wake of protests across the United States and UK over the use of excessive force by police. Avery Browne, chief of the Golden Gate Division of the Highway Patrol, reportedly confirmed the incident and said that the officers had previously joined protesters to listen to their conversations and were also sending information back to the Highway Patrol and the Oakland Police Department.

Browne reportedly said that there was a "mob continuing to advance upon them” after it was revealed that they were police officers. “At that time an individual accused one of our employees or recognized him as being a police officer and started yelling ‘Police! Police!’” Browne said, according to Los Angeles Times.

The crowd "encircled the officers and began to close in," while one man hit one of the officers in the back of the head. Oakland police officers reportedly arrived at the site, following which the crowd dispersed.

“We know that it is upsetting and disturbing anytime a firearm is displayed,” Browne reportedly said, Thursday. “We want to prevent someone from getting hurt. And last night, these guys put their lives on the line because a group of individuals chose to destroy small businesses.”

The man accused of punching the officer was charged with felony battery and assault. The officer was treated for “soft tissue injuries,” Browne said, according to The Huffington Post. Police are reportedly searching for a woman who allegedly kicked the officer who was attacked.

Protests in California have continued almost every night since Saturday over a Staten Island grand jury decision not to indict NYPD Officer Daniel Pantaleo in the chokehold death of Eric Garner, which was preceded by a grand jury decision not to indict Officer Darren Wilson in the shooting death of Michael Brown in Ferguson, Missouri.