Get breaking news alerts and special reports. The news and stories that matter, delivered weekday mornings.

By The Associated Press and Phil Helsel

A Florida sheriff’s deputy died Tuesday after he was shot several times from behind after serving a domestic violence injunction against a man at a Shalimar attorney’s office, authorities said.

The gunman was later shot and killed by police.

Okaloosa County Sheriff’s Deputy Bill Myers, 64, was shot by Joel Dixon Smith, 33, outside the law office at around 8:20 a.m. and one of the bullets struck him in the back of the head, the Okaloosa County Sheriff’s Office said.

Let our news meet your inbox. The news and stories that matters, delivered weekday mornings. This site is protected by recaptcha

Okaloosa County Sheriff's Deputy Bill Myers, 64, is seen in this photo released by the sheriff's office. Meyers was fatally shot by a gunman outside a law office in Shalimar, Florida, Tuesday. Michele E. Nicholson / Okaloosa County Sheriff’s Office

The order being served by Myers had barred Smith from possessing firearms, and Myers was walking to Smith's car to get retrieve some weapons when Smith pulled out a concealed gun and began shooting, The Associated Press reported.

"He was a sick little coward," Okaloosa County Sheriff Larry Ashley said, holding back tears.

Smith then fled to a nearby Comfort Inn about 9 miles away in Niceville, where he barricaded himself in a room, the sheriff’s office said.

When a special response team fired tear gas into the room, which Smith had previously rented, he charged out with a weapon and was fatally shot, Ashley said.

Myers joined the department in 1989, retired in 2013, and was re-hired on a part time basis to serve civil orders.

"He served this community with distinction for decades. He was loved, admired, and respected for his dedication to the law enforcement profession," Ashley said in a statement.

"We pray for his soul and for his family and we ask that the community pray for them as well, and for all the men and women who have the courage in these troubled times to put their lives on the line for others," Ashley said.

Smith had been arrested for domestic battery in 2008, Ashley said, without providing further details.