PETALUMA -- An off-duty Marin County sheriff's deputy who interceded in a domestic dispute involving a friend in Petaluma was shot and killed early Tuesday by a parolee, who was then shot dead, authorities said.

Deputy Jim Mathiesen, 49, a nine-year department veteran assigned to the Marin County jail, was shot shortly after midnight by Thomas Edwin Halloran, 28, on the 800 block of Liberty Road in Petaluma, said Sonoma County Assistant Sheriff Lorenzo Duenas.

Mathiesen had been called to the home by Halloran's 22-year-old ex-girlfriend, who along with her family was close friends with the deputy, Duenas said.

Mathiesen, who lived in Petaluma, leaves behind a wife and two children.

"This is tragic news," said Marin County Sheriff Bob Doyle. "Jim died trying to help others. He was known for his kindness and his helpful nature."

Mathiesen "was trying to help out, as any deputy sheriff or officer would do, and it ended up in a real tragic situation," Duenas said.

Mathiesen arrived at the home about 11:30 p.m. and was told that Halloran, whose relationship with his girlfriend had recently ended after four months, had been texting death threats to the woman and her family, Duenas said.

The woman did not have a restraining order against Halloran, authorities said.

About 20 minutes after Mathiesen arrived at his friend's home, Halloran showed up. The deputy went outside and was asking him to leave when Halloran pulled out a handgun and shot Mathiesen twice in the chest, Duenas said.

Mathiesen was unarmed, authorities said.

Halloran then took his ex-girlfriend's mother hostage, threatening to shoot her if he did not find the woman, Duenas said.

Halloran forced her into a garage and was trying to put her in a car when the ex-girlfriend's brother shot him twice, Duenas said.

Both Halloran and Mathiesen died at the scene. The names of the family members involved were not released.

Halloran was on parole for making threats and had numerous arrests in Marin and Sonoma counties. In 2008, he was arrested for allegedly threatening to kill a previous girlfriend in Petaluma, authorities said. He had also served as a confidential drug informant for a Marin County task force.

On his Facebook page, Halloran changed his status from "in a relationship" to "single" on July 9. On Friday, he wrote, "Time to relax and enjoy the single life staying single forever."