A longtime Florida deputy was fatally shot Friday and another was wounded while trying to serve an eviction notice at an upscale gated community, the local sheriff said.

The locksmith who was with them was also wounded when the suspected gunman began “indiscriminately firing” at them, Indian River County Sheriff Eric Flowers said at a news conference.

Flowers said the suspect, whom he identified as Michael Halberstam, was also wounded by gunfire.

“The bad guy is currently in surgery and is in critical condition,” Flowers said.

The deputy “who made the ultimate sacrifice” was 47-year-old Terri Mashkow, who had worked for the department for exactly 25 years and 16 days, Flowers said.

The wounded deputy is Florentino “Tino” Arizpe, who has been on the force for 25 years, the sheriff said.

“It’s been an awful day,” Flowers said, noting that Mashkow is only the second “line of duty” death at the department in 100 years.

Mashkow, the sheriff said, had started out as a dispatcher and worked her way up to patrol officer, a job she had performed for two decades. She had recently been reassigned to the legal process civil unit.

Halberstam, who was born in 1988 and previously lived in Virginia, had been living at his mother’s home at the Bermuda Club, which is located near Vero Beach.

Flowers said Halberstam’s mother was trying to evict her son and that the department had responded to complaints at the house seven times just this month.

“Almost all of them from the mother calling about him,” Flowers said.

Nevertheless, Flowers said Halberstam “was not someone that was on our radar.”

“This was not someone that we were actively engaged with,” the sheriff said. “This was a standard call for service.”

Halberstam’s mother was outside the house when Mashkow, who was also accompanied by Sergeant Gary Carlos, arrived to remove the son from the premises, Flowers said.

While the officers were in the entryway, Halberstam grabbed a firearm and opened fire, hitting Arizpe in the shoulder, Flowers said.

Mashkow and the locksmith were also hit by gunfire, the sheriff said. Carlos was not, but he and possibly Arizpe were able to return fire.

“Until we conduct our full investigation, we will not know whether or not deputy Terri fired her weapon,” Flowers said.

Flowers did not name the locksmith.

The wounded were taken to HCA Florida Lawnwood Hospital in nearby Fort Pierce with a police escort, Vero Beach Mayor John Cotugno told local NBC affiliate WPTV earlier.

Halberstam has two prior arrests from Virginia on his record: A 2006 narcotics charge and a 2015 misdemeanor assault charge, Flowers said.

Investigators are now scouring through Halberstam’s posts on social media, some of which were directed at the sheriff’s department, Flowers said.

“They’ve identified some strange posts on social media, identified that he was fired from UPS, that he made some terrible comments about them, and that he’s been posting some negative ideas about the Indian River County sheriff’s office on his Facebook page,” Flowers said.

Karen Tomaszewski, a spokesperson for UPS, said nobody named Michael Halberstam has worked for the company in three years.

The Bermuda Club, according to its website, is located on Orchid Island and comprises “93 West Indies style single-family homes” that are a short walk from the beach and the Atlantic Ocean.