A sheriff's deputy who died in a mass shooting at a California bar was shot five times by a gunman who massacred 11 others, but the officer was killed by friendly fire, authorities said Friday.

Sgt. Ron Helus was fatally shot in the heart by a California highway patrolman who had joined him in the chaotic gun battle at the Borderline Bar & Grill in Thousand Oaks on Nov. 7, Ventura County Sheriff Bill Ayub said.

"It was just a tragic detail that unfolded so rapidly, in my view it was unavoidable," Ayub said. "They were ambushed almost immediately."

Investigators did not offer any more insight into what drove Ian David Long, 28, to storm the country-western bar during a weekly event for college students.

Helus and the CHP officer returned fire with high-powered rifles, but Long was not struck by any of their rounds and took his own life after the firefight.

Helus was wearing a bullet-proof vest when he was shot, but officials did not say where the bullet entered his body. His wounds from Long's handgun were serious, but potentially survivable, said Christopher Young, the chief medical examiner.

The CHP officer was only identified as a 9-year veteran of the force. He is on leave. The officer was notified Thursday of the finding by L.D. Maples, chief of the CHP's Coastal Division.

"He had no clue it was coming," Maples said. "It surprised all of us. He's devastated. He's a consummate professional, well-trained, military background."

Ayub said the finding that Helus was killed by another lawman did not diminish the heroism shown by both men. When officers arrived, more than 100 patrons, several of them bleeding, were jumping out windows and running for their lives while gunfire was heard inside the large bar.

"We believe that Sgt. Helus was clearly not the intended target of the CHP officer, which further illustrates the extreme situation that both men faced," Ayub said. "Sgt. Helus and the CHP officer both knowingly and willingly went into what can only be described as a combat situation, risking their own lives to save others. It is a fact that many lives were saved that night. It is also an unimaginable tragedy that many lives could not be saved."

In addition to the dead, 22 people were wounded, many with cuts from glass after jumping through broken windows to escape.

Long threw smoke grenades into the bar, obstructing what employees and bar-goers could see before he opened fire. He used a flashlight with a laser sight attached to his .45-caliber semi-automatic pistol as he fired.

Panicked revelers ran for the doors, dived under tables and piled on top of each other in an effort to dodge the gunfire.

Long, a Marine veteran, took a tactical position and ambushed the officers when they entered the bar.

Helus, a 29-year veteran of the department, was close to retirement.

Ayub said that despite the source of the fatal shot, Long alone was to blame for Helus' death.

"It is important to remember that the horrific circumstances at the Borderline Bar and Grill on that Wednesday night exactly one month ago today were caused by the evil act of one individual," Ayub said. "He went there with a plan and a purpose and that was to take innocent lives. The burden lies solely with him, not with those who tried to save lives, those who tried to escape and certainly not with those who died while simply trying to enjoy an evening with friends."

___

Associated Press writers Brian Melley and John Rogers in Los Angeles contributed to this report.