THOUSAND OAKS, Calif. (AP) - A sheriff's sergeant who died in a mass shooting at a Thousand Oaks 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 Patrol officer who had joined him in a firefight with the gunman at the Borderline Bar & Grill 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."

Ayub said the fatal shot did not diminish the heroism shown by the officers. The CHP officer was not identified, but is a 9-year veteran of the force who is on leave.

Investigators did not offer any more insight into what drove Ian David Long, 28, to storm the country and western bar at an event for college students.

Long took his own life after the gun battle with the two officers.

Long threw smoke grenades into the group of revelers, obstructing what they could see, before he opened fire.

Then he used a flashlight with a laser sight attached to his .45-caliber semi-automatic pistol as he fired.

Panicked revelers smashed windows to flee, dived under tables and piled on top of each other in an effort to dodge the gunfire.

The first two officers to arrive at the scene, Helus and a California Highway Patrol officer, saw at least 100 people fleeing the bar.

Long had gotten into a tactical position and fired on them when they entered, killing Helus. The 29-year veteran of the department was close to retirement.