Martin Wirth spent recent years fuming over police brutality and corrupt mortgage companies, fueled by his own run-ins with the law and a long battle to save from foreclosure his two-story home in the Colorado mountains.

That fight came to a violent end Wednesday when the 58-year-old shot three law enforcement officers trying to serve an eviction notice, killing one and wounding the others. Officers fired back, killing Wirth.

Some close to Wirth struggled to reconcile the shooting with their memories of him as a well-intentioned activist, while others recalled a quick-tempered man with a propensity for violence. He wrote disparagingly of the government and police in seething posts on his Facebook page.

"They are a brutal impediment to human progress a danger to us all," one post said. "Because I write such things, cops want me dead."

Aware of the danger, eight officers from the Park County Sheriff's Office went to the home in a hillside neighborhood north of the town of Bailey to serve what authorities described as a "high-risk" eviction notice.

Wirth appeared on the deck of the house when they arrived, then went back inside, the sheriff's office said. For unknown reasons, officers followed him in, and Wirth opened fire, leading to a shootout.

The gunfire killed Cpl. Nate Carrigan, a 13-year veteran of the agency. One of the wounded deputies underwent surgery for life-threatening injuries and was in critical condition. The other was treated and released after a bullet grazed his ear.

Wirth had several brushes with the law over the years, including a January arrest for eluding a police officer, obstructing a law enforcement animal, and driving without insurance and a license, court records show.

A man who got a protection order in 2005 against Wirth said he made violent threats while enrolled in court-ordered drug and alcohol counseling. Dan Spykstra, who was running the program at the time, said he confronted Wirth after Wirth went off on an employee.

Wirth said he would put a bomb in Spykstra's mailbox and said, "I have you in my crosshairs," according to Spykstra.

"I did not think they were jokes," Spykstra said. "He was a person who was constantly saying the government was out to get him. Nothing was his fault, it was always someone else's."

Spykstra's son played on the local high school football team, which Carrigan and sheriff's Capt. Mark Hancock, who was wounded, coached.

"He was always very supportive and wise beyond his years, a really good kid," Spykstra said of Carrigan.

Wirth owned his home until March 2014, when Fannie Mae, the government-controlled mortgage company, took ownership after he lost a court battle over his foreclosure.

"It seems to me that he was just pushed to the end of his rope, and he tried every single approach to addressing his grievances, and at the end, he chose to not let them take his house away from him," said Tim Holland, who was involved in the Occupy Denver movement with Wirth. "It's the middle of winter in the mountains. Where was he going to go?"

The Colorado Foreclosure Resistance Coalition, an organization aligned with the Occupy movement, said it helped Wirth with his foreclosure struggles.

Wirth "took extraordinary measures in the past several years to shed light on and bring an end to the mass of unjust foreclosures that have ruined the lives of so many," the group said.

After he lost his foreclosure case, Wirth sued Colorado Gov. John Hickenlooper, the state attorney general and a judge in 2013. The federal lawsuit claimed that state foreclosure laws were unconstitutional and that Wirth was "in imminent danger of being wrongfully deprived of home and property while also being threatened with an armed and forcible entry onto the property and into the home."

He asked a federal judge to block Park County from selling his home, evicting him or forcibly entering the house and to strike down several state laws. A federal judge dismissed the lawsuit last September.

Wirth ran for the state Senate in 2014 as a Green Party candidate, but he lost to an incumbent Republican.