Novelist Michael Peterson agreed to a plea deal Friday that enables him to maintain his innocence even as he acknowledges prosecutors have enough evidence to convict him of manslaughter in his wife’s death. The district attorney, for his part, insisted that he’s guilty.

Wearing a dark suit and flanked by his defense team, Peterson answered questions from Superior Court Judge Orlando Hudson and agreed to the terms of his Alford plea.

But before he could leave, he got a scolding from Candace Zamperini, whose sister Kathleen’s body was found at the bottom of a staircase in their North Carolina mansion on Dec. 9, 2001.

Zamperini described Peterson’s accounts of his wife’s death as a “fictionalized story” and berated her former brother-in-law, telling him “Kathleen was the best person you ever had in your life.”

“This hearing is as close to justice as anything that can be found,” Zamperini said. She called the wording of the Alford plea “meaningless.”

Peterson, 73, still maintains that he didn’t kill his wife. His initial murder conviction and life sentence were overturned after questions arose about the reliability of a key witness, among other things.

“Right now, I can live with this. It’s not fair, It’s not right,” he told reporters after the hearing. “I’m innocent. This deal is not a good one for me . . . It is a great deal for the district attorney.”

Peterson said making this plea was his most difficult decision.

“The second most difficult thing I ever did in my life was to sit through that trial and listen to lies, perjury, fake evidence, made-up evidence, withheld evidence, unconstitutional searches so many times, I wanted to jump up and scream, ‘Liar! This is not right,” Peterson said.

Alford pleas are treated generally the same as guilty pleas by criminal courts, but some defendants prefer them psychologically or believe they may offer advantages if they later face a civil lawsuit, according to a blog written by University of North Carolina legal scholar Jeff Welty.

Durham District Attorney Roger Echols said his office maintains that Peterson is responsible for the death of Kathleen Peterson.

“There could be a need for Mr. Peterson to spin things in the media the way that he wants to, and that’s fine. That doesn’t change what my duty is and the reasoning and the logic behind the decisions that I make and what we make in this office,” Echols said in an interview Friday. “The law will treat him as guilty, and he will forever be treated as guilty.”

Peterson’s fictional works include “The Immortal Dragon,” ”A Time of War,” and “A Bitter Peace,” novels centered on the conflict in Vietnam, where he served as a Marine.

His trial in 2003 had all the makings of a made-for-TV movie — and one was filmed, along with a multi-part documentary. Salacious details included his bisexuality; the death of a family friend whose body also was found at the bottom of a staircase years earlier in Germany; and the state blood spatter analyst whose discredited testimony was reviewed by the state’s unique innocence commission.

The story also offered mystery: the prosecution did not describe a murder weapon, nor a clear motive.

Through all of it, Peterson’s two biological sons with his wife support him, as do the two sisters he raised, whose mother is the woman who died in Germany.

In 2007, Atwater reached a $25 million wrongful death settlement with Peterson, under which he acknowledged no guilt, that would have been payable had his murder conviction stood.

But the verdict fell apart after Duane Deaver of the State Bureau of Investigation was fired in 2011 following an independent audit that found problems in 34 of his cases.

Defense attorney David Rudolf cited statements from jurors that they relied on Deaver’s discredited testimony, and the original trial judge, Orlando Hudson, ordered a new trial. Peterson was released from prison and slowly gained more freedom.

Hudson declined in November 2016 to drop the charges, however. And Peterson said his sons advised him thereafter to settle the case somehow, because they believed he would never get a fair trial from the police or prosecutors.

“They would do anything to convict me. And I am not going to put my life and my freedom in their hands,” he said.

Peterson now lives in a 1,200-square-foot condo, a tenth the size of the mansion where his wife died. It is more than enough, said the grandfather of two. He said he plans to visit family, and write another book.

“For five years, I’ve lived with this over my head,” he said. “… But now, on Friday, I’ll be free. I haven’t really absorbed that yet.”