SAN DIEGO — A security officer at Old Town Transit Center stabbed a man who attacked him Friday and tried to steal his gun, after which the assailant ran off and was taken into custody following a search of the area, officials said.

The would-be firearm thief approached the lawman about 1 p.m. at the train and bus depot in the 4000 block of Taylor Street and "immediately grabbed his service pistol and violently pulled on it, trying to remove it from its holster," San Diego Police Officer Dino Delimitros said.

RELATED: Surveillance video shows optometry store burglarized in Sorrento Valley

"The security officer was able to retain his weapon and defend himself with his duty knife," Delimitros said. "The officer suffered minor injuries due to being punched in the face several times."

The wounded assailant ran off to the south.

Police combed the vicinity for the alleged attacker, eventually finding him underneath a bridge near the transit center. The suspect, whose name was not immediately available, was arrested and taken to a hospital for treatment of stab wounds to his torso.