It was just 9 a.m. Thursday and the Berkeley Patients Group, a medical cannabis dispensary at 2747 San Pablo Ave. in Berkeley, wasn’t even open yet.

But the dispensary’s security guard was sitting in his car out front. We’re not entirely sure what he was doing there but police are now glad he was.

Without warning, a guy opened the passenger-side door of the guard’s car and hopped in the front seat. He wasn’t there to chat and immediately pointed, what appeared to be a gun, at the guard. He then demanded the keys to the 2500-square-foot dispensary, one of four in the city, I believe.

The security guard, who said he didn’t have the keys, then got out of the car, grabbed the suspect and started “screaming” for police, who weren’t far away on routine patrol, police spokesman Officer Andrew Frankel tells me.

The suspect successfully freed himself and ran towards a 6-8-foot tall fence that has razor tape on the top.

Think of the blades of a saw sitting upright on top of a fence and you’ll get the idea of what razor tape looks like. Ouch.

But this security guard wasn’t letting the would-be thief get away and somehow stopped him from climbing the fence.

Turns out the gun was fake. Police weren’t sure if the security guard knew the gun wasn’t real and they don’t advocate that people go after potentially armed suspects. But in this case, all turned out well.

“I hope he’s getting more than minimum wage cause that guy earned every penny of it (Thursday),” Frankel said.