A St. Paul man pleaded guilty to threatening staff last summer in the mayor’s office — and the incident ultimately may have saved his life.

Jeffrey Karl Weissbach was upset over the city’s handling of a homeless encampment near his house, according to his attorney.

“Sometimes miracles come wrapped up as felonies,” Brian McNee Marsden said of his client and friend’s angry outburst this past July.

Police showed up at the 62-year-old’s house on the 300 block of Colborne Street after learning about repeated threatening phone calls he made to City Hall about a homeless encampment near his house, court records say.

Frustrated about the city’s response to his concerns about the encampment, Weissbach started calling repeatedly, declaring in one voicemail: “It’s all-out war and I will hunt you down and kill you like a dog,” court records say. Weissbach keeps two rifles in his house.

Weissbach, who Marsden described as a “great guy,” had a heart attack during his arrest and collapsed. Officers rushed him to a hospital, where he was quickly led into triple bypass surgery.

Unbeknownst to Weissbach, in the past year he was getting sicker and sicker, and as a result “crabbier and crabbier” as his brain was starved of adequate oxygen, Marsden said.

“So they literally saved his life,” Marsden said of the officers who arrested him.

Now, the father of a 15-year-old son is eating better and feeling more like his old self, which Marsden said is not typically the type to threaten anyone.

“He is pretty relieved to be putting this behind him,” Marsden said. “Ironically enough, this was a miracle for him … He needed intervention of a significant kind.”

As part of his plea, which was entered in Ramsey County District Court Thursday, Weissbach is expected to avoid jail time as well as a felony conviction for the threats of violence count when he is sentenced in February.