The suspect was later killed in a confrontation with police.
Okaloosa County Deputy Bill Myers, 64, died Tuesday after he was shot multiple times in the head and back.
"He had an ability to make those around him smile, especially his young granddaughter who he adored and took to Disney World as often as he could," Okaloosa County Sheriff Larry Ashley said, fighting tears during a news conference late Tuesday.
Myers, a 25-year department veteran, had retired in 2013 but returned to work in January, Ashely said.
"He was a part of our family. We are a family here," Ashley said.
Joel Dixon Smith, 33, was being served a domestic violence restraining order at the lawyer's office just blocks from the sheriff's office. He was supposed to be turning over his guns to Myers, 64, when he pulled out a concealed weapon and shot the deputy multiple times, authorities said.
Smith, a postal worker, fled in his vehicle to a Comfort Suites hotel about 10 miles away in Niceville, where he had previously booked a room. He barricaded himself inside and deputies eventually fired tear gas into his room. He charged out firing and was fatally shot by deputies, Ashley said.
No one else was hurt.
Smith had been arrested in 2008 for domestic battery, Ashley said, but had no other details. The restraining order was meant to protect Smith's wife.
Smith was a rural Postal Service carrier, beginning in Niceville in 2013, the agency said in a statement.
Annie Allen works at an awning business next to the law firm. Allen said she and her boss, store owner David Wray, were starting their day when as many as eight gunshots rang out.
"We heard 'pop, pop, pop,'" she said.
Allen called 911, and Wray went to check things out.
Wray said he initially thought a nearby store had been robbed. He spotted Myers' patrol car and ran over thinking to tell a deputy about the possible robbery but instead saw Myers bleeding.
Wray said he was stooped over Myers when a well-dressed man walked out of the law office. Wray said he asked if anyone had called 911, but the man just continued to his truck. That's when another woman screamed that the man was the shooter.
"It was like I was in a movie," Wray said. "I just couldn't believe any of it."
Wray said he used his phone to take photos of the fleeing truck before trying to follow it in his own vehicle.
"I thought I'd chase him, but there was a lot of traffic," Wray said. "I'm not James Bond. I didn't want to get anybody hurt, so I went back."
At the scene of the shooting, Wray said he and another man tried to talk to the deputy, but he didn't respond.
"It was the saddest thing I'd ever seen," Wray said. "I cradled his head for a while. He was bleeding profusely."
At the Comfort Suites, guest David Bump of Ozark, Alabama, said he awoke Tuesday to deputies pounding at his room.
"I opened the door and they had their guns drawn," he said.
Bump said officers took him and other guests across the street, where they spent hours watching the standoff.
"When they brought the guy out, he was on a gurney with his face covered," said Bump, who was working in the area on a construction crew.
Deputy Myers was white. Smith listed himself as Native American on one voter registration and white on a more recent one.