This post has been updated.

Prince William Police Capt. Gregory Smith said he had just finished giving directions to a family of three outside the eastern district police station last week when the sole man in the group struck him without warning.

Smith said he was crossing the street outside the Garfield District Police Station on Tuesday when two women and a man stopped him to ask directions to the magistrate’s office. After he pointed them in the right direction, Smith said, a man who was lagging behind the women punched him in the face. Smith, who said he did not see the attack coming, said he began to defend himself until police officers in the station came to his aid.

“I do a lot of preaching to troops about safety and awareness, and that’s one of the first things that entered my mind,” said Smith, 50. “Here is a real-life example of how sudden things can happen, and it’s a reminder we can’t let our guard down.”

Daniel Mehdi Razjooyan-Sosa, 25, of the 12800 block of Hunterbrook Drive in Woodbridge, was charged with assault and battery of a law enforcement officer on Sept. 6 and is being held without bond. Smith suffered some minor injuries to his face but returned to work the same day.

“We are very fortunate he wasn’t hurt more seriously,” Prince William Police Chief Charlie T. Deane said. “It’s not unprecedented for an officer to be attacked without” warning.

Deane said this wasn’t Razjooyan-Sosa’s first run-in with the law. He was charged in August with obstruction of justice in Fairfax County. He was out on bond and waiting an October court hearing. Deane said Razjooyan-Sosa was also charged in 2004 for setting fire to a wooded area in Fairfax.

“It’s unfortunate he was out on the street,” given his history, Deane said. “But I’m glad he didn’t have any weapon and [Smith’s] injuries were relatively minor.”

Deane said random attacks on officers are a growing concern across the nation. In 2006, two Fairfax County officers were killed when a gunman opened fire in a police station parking lot, and in 2009 four police officers in Lakewood, Wash., were killed when a man fired at them in a coffee shop.

Just this January, Deane said, a gunman opened fire in a Detroit police station, wounding four officers.

“There is a false sense of security at police stations, but they are magnets” for random attacks, Smith said.