PORTLAND, Maine — The man who killed Pamela Smart’s husband in a notorious New Hampshire case involving a love triangle that ended in a 1991 murder was released on parole from Maine State Prison in Warren Thursday after serving nearly 25 years, authorities said.

William Flynn, now 41, was a just teenager when he admitted to shooting and killing Smart’s husband, Gregg, in his Derry, New Hampshire, home. Flynn testified he had done so because Pamela Smart, then 22, had threatened to break up with him if he would not.

Flynn was convicted of second-degree murder and sentenced to 99 years in prison, with all but 25 years suspended, according to court records. He was granted parole in March after serving his sentence in a prison in Warren, Maine.

The televised and much-hyped case became a decades-long media sensation, eventually inspiring an episode of the television series “Law and Order” and a film starring Nicole Kidman, as well as many true-crime novels.

Prosecutors said Flynn shot Gregg Smart through the head with a handgun while a friend and co-conspirator, Patrick Randall, held a knife to his throat.

Randall was released from a New Hampshire prison Thursday.

Flynn, a 16-year-old student at the time of the murder, met the newlywed Smart at a Hampton, New Hampshire, school where she worked as a media coordinator. Authorities said Smart seduced Flynn in what became a sexual affair.

Flynn and three co-conspirators eventually testified against Smart, saying she had helped orchestrate the murder of her husband.

Smart, who admitted having an affair with Flynn but has repeatedly denied any knowledge of the plot to kill her husband, was sentenced to life in prison for being an accomplice to first-degree murder, conspiracy to commit murder and witness tampering.

She is serving her sentence at a maximum-security prison in New York.