An under cover officer points his gun at the crowd while his partner subdues a protester who struck him in the back of the head, as demonstrations continue for a fifth night in Oakland on Wednesday, Dec. 10, 2014. less

An under cover officer points his gun at the crowd while his partner subdues a protester who struck him in the back of the head, as demonstrations continue for a fifth night in Oakland on Wednesday, Dec. 10, ... more

An under cover officer points his gun at the crowd while his partner subdues a protester who struck him in the back of the head, as demonstrations continue for a fifth night in Oakland, CA, on Wednesday, December 10, 2014. less

An under cover officer points his gun at the crowd while his partner subdues a protester who struck him in the back of the head, as demonstrations continue for a fifth night in Oakland, CA, on Wednesday, ... more

An undercover California Highway Patrol officer who was attempting to infiltrate a demonstration against police brutality in Oakland pulled a gun on the protesters after he and his partner were outed and the partner was attacked.

The undercover work — captured by a freelance photographer working for The Chronicle — raised questions about tactics employed by police and protesters as authorities seek to get a handle on rallies that have flooded the streets of Oakland, Berkeley and San Francisco, at times shutting down freeways and devolving into vandalism and looting.

Elementary school in Oakland opens time capsule from 1927San Francisco Chronicle

Brides of March walk through San FranciscoSan Francisco Chronicle

WildCare rescues Western scrub jay from rodent glue trapWildCare

The Regulars: The CarpenterJessica Christian

Massive fire in San Francisco's North BeachDavid Essling

Avery Browne, chief of CHP’s Golden Gate Division, said the agency and other police departments have had plainclothes officers dressed in protester attire walking in these marches since the first demonstration Nov. 24, and he said they will continue to employ this tactic despite Tuesday’s incident.

He said before the officers were outed Tuesday, they were able to collect enough information to prevent four more freeway shutdown attempts.

“We will use all of the avenues we can to keep the public safe and gather that information so we can be responsive and be in the proper position,” he said.

About 50 people were marching near Lake Merritt just after 11:30 p.m. Wednesday when some of the demonstrators began calling out two men who were walking with the group, said the freelance photographer, Michael Short.

“Just as we turned up 27th Street, the crowd started yelling at these two guys, saying they were undercover cops,” Short said Thursday. “Somebody snatched a hat off the shorter guy’s head and he was fumbling around for it. A guy ran up behind him, knocked him down on the ground. That guy jumped backed up and chased after him and tackled him and the crowd began surging on them.

“The other taller guy had a small baton out,” Short said. “But as the crowd started surging on them, he pulled out a gun.”

Chief Browne said the officer also pulled out a badge and identified himself as law enforcement, as is department policy, though Short, other members of the media and protesters reported that they did not see a badge.

The officers, who Browne said he is not identifying, had been trailing the crowd in an unmarked car and began following on foot at Ninth and Harrison streets, after vandals marching with the group had smashed the windows of a T-Mobile store in Oakland’s Chinatown neighborhood and made off with merchandise. A nearby Wells Fargo ATM was also damaged.

When the protesters called them out as law enforcement officers at 27th and Harrison, a man punched the shorter officer in the back of the head and ended up struggling with him on the ground, Browne said.

The crowd of “about 30 to 50” continued to advance, and the officer “transitioned from his baton to his firearm,” according to Browne. He then pointed the gun at the protesters and panned the crowd to keep them away from him and his partner, who was still on the ground fighting with an attacker.

“'Chief, I didn’t know if I was going to make it out of this thing alive,’” Browne said the officer told him. “'They were coming after us, they had already punched my partner in the head. I didn’t know if we were going to make it out alive.’”

The man accused of punching the officer was booked into county jail on suspicion of felony assault on a peace officer.

While the officer fought with the man on the ground, a blonde woman ran up and kicked him the head, Browne said. She was not arrested, but the officer suffered head injuries and is displaying concussion-like symptoms.

“We know it’s upsetting, we know it’s disturbing, every time a firearm is drawn, whether in a protest situation or in a felonious car stop,” Browne said. “But we need to understand that these officers were under attack.”

Short said the officers were wearing street clothes and had their faces covered with bandannas. Browne confirmed this and though he described them as “plainclothes” and not undercover, he said it was common for these officers to mimic the dress of the other protesters “so they blended in with the crowd.”

He said the main objective of these officers was to collect information on where the group was going. He said they were able to gather that information from their car in the back, overhearing plans to take Highway 24 and Interstate 80 twice on Tuesday and enabling other CHP officers to prevent those attempts.

Browne said the Oakland Police Department was aware of the CHP’s plainclothes operations, and that they had an officer in Berkeley’s emergency operations center. Oakland police did not return calls seeking a comment.

Several protesters took to Twitter to say that the officers had actually instigated acts of vandalism and were banging on windows alongside others.

Short said he did not see the officers’ actions because protesters had surrounded him and had tried to take the memory card out of his camera. Noah Berger, another freelance photographer, was similarly accosted by protesters.

But Browne said though the agency was investigating the use of force, the officer’s arrest and events leading up to it, he said he has not received reports that the officers instigated vandalism. In fact, they only got out of the car to gather information on the vandals, he said.

The officer that drew his weapon is still on active duty, Browne said. Both officers are assigned to the auto theft unit of the agency’s detective bureau.

The march had earlier been peaceful, beginning in Berkeley with hundreds of participants calling for justice for Michael Brown and Eric Garner, two unarmed black men who were killed by white police officers in Missouri and New York. The recent demonstrations were set off when grand juries declined to file charges in the cases.

Protesters on Wednesday disrupted traffic at times, as well as a UC Berkeley lecture given by PayPal co-founder Peter Thiel, but did not take over any freeways.

In addition to the man arrested in connection to the officer attack, CHP arrested another protester in Oakland on suspicion of public intoxication, Browne said.