A Kentucky deputy killed in an ambush that left three officers dead in a small Appalachian town was laid to rest Tuesday.

Floyd County Sheriff John Hunt fought back tears at the funeral for his deputy and longtime friend, William Petry, who along with two other officers walked into a hail of bullets from a gunman holed up in his home Thursday evening.

Petry, a veteran officer who joined the Floyd County sheriff’s office after retiring from the state police a few years ago, was honored Tuesday during an emotional funeral service in Prestonsburg, the county seat.

“William loved law enforcement. He loved the job. He loved the people,” Hunt said in a eulogy for his longtime friend Tuesday morning. “He is a hero … and I know he will never be forgotten.”

The shooting is likely Kentucky’s deadliest incident for law enforcement in nearly 100 years and one of the deadliest in the nation since 2016, when three Baton Rouge, Louisiana, police officers were fatally shot by a gunman. Petry and Prestonsburg police Capt. Ralph Frasure, both 60 years old, died at the scene and Prestonsburg Officer Jacob Chaffins, 28, died in a hospital Friday night. A police dog was also fatally shot.

The man arrested in their deaths, 49-year-old Lance Storz, was taken into custody in the small community of Allen after family members helped police secure his surrender Thursday night.

Dozens of uniformed law enforcement officers gathered Tuesday at the funeral at Prestonsburg’s Mountain Arts Center. Petry’s family gave permission for media to livestream the event on local news stations. Frasure, Chaffins and the police dog, Drago, will be laid to rest after funeral services later this week.

Chaffins, who joined the department in 2019, left behind a wife and young daughter. He also served on the Prestonsburg Fire Department and was a member of the National Guard. Frasure had been married for more than 40 years and had four grandchildren. He had been an officer with Prestonsburg police since 1983.

Frasure’s daughter wrote in a Facebook post Friday that her father “was a great man who loved his family like no other.”

“An evil evil man took my daddies life today,” Stacy Frasure McGuire wrote. “I know I should forgive but how do I do that?”

Floyd County Deputy Kevin Thacker said he took a phone call from Petry last week, a typical issue about a towed car, he said. But at the end of the call, as had become ritual, Petry told him he loved him.

“That was his last words to me,” Thacker said at the funeral. “And I’ll never forget that.”

Police went to the house in Allen on Thursday after a family member called to say Storz’s wife was being held in the home against her will and was being abused, Hunt said in a news conference over the weekend. The wife was waiting for them when they arrived, telling the officers Storz was asleep, so she was able to get outside. Four officers, including Petry, returned to serve a protective order against Storz, Hunt said. Storz watched them approach from a window and began shooting, Hunt said.

The officers’ deaths were the most in a single incident since a 1923 prison riot in Eddyville that left three corrections officers dead, Prestonsburg Police Deputy Chief Ross Shurtleff said Sunday. Storz is facing three counts of murder of a police officer and is being held in jail on a $10 million cash bond.

Petry’s death will be a huge loss for the department, Hunt said, because he worked so well with younger, inexperienced officers who revered his experience and calm.

The young officers “respected him like nobody I’ve ever seen in such a short time,” Hunt said.

Four other officers were injured in the shooting, though none wounds were life-threatening, state police said over the weekend. One civilian was also hurt in the shooting, state police said.