A security guard accused of shooting and killing a man outside a marijuana dispensary in San Bernardino was arrested on Tuesday.

Lance Cobb, 24, was under arrest for murder after what started as a struggle with another man turned into a fatal shooting.

The gunfire occurred shortly after midnight in the parking lot of the dispensary in the 2600 block of Foothill Boulevard, police said.

"He was an armed security guard who was on site and apparently the dispensary had just closed for the evening when the male victim arrived at the location," said Lt. Mike Madden of the San Bernardino Police Department.

According to investigators, 37-year-old Thomas Loftus was acting erratically and confronted Cobb about speaking to a manager.

That's when, according to police, Cobb pulled out his gun and shot Loftus in the upper thigh.

Responding officers found the victim suffering from a gunshot wound at the scene. He was transported to an area hospital, where he later died.

Initially, investigators believed it was an act of self-defense, but officials said footage of the incident led to the arrest.

"Further investigation has been developed and indicates that the security guard possibly acted erroneously," Madden added. "He has now been taken into custody for murder."

Customer Jesus Perez said he wasn't surprised to learn about the shooting due to the rough area, but he was shocked by Cobb's arrest.

"He could have probably done something different -- he could have Tazed him, apprehended him. There could have been many ways he could have done this," he said.