The accused gunman in a deadly love triangle accepted a plea agreement Monday that will send him to prison for 25 years and four months in exchange for testifying against a woman who allegedly plotted with him in killing her husband in Tehachapi more than two years ago.

Jonathan Hearn, 26, pleaded guilty at about 2 p.m. to crimes including voluntary manslaughter, attempted murder and poisoning before Judge Charles R. Brehmer. Originally charged with first-degree murder, Hearn had faced life in prison if found guilty.

For the deal to remain intact, the judge said Hearn must cooperate with authorities and testify against co-defendant and former alleged lover Sabrina Limon. He must also issue an apology to the family of victim Robert Limon.

When questioned by Brehmer, Hearn, wearing a dark-colored suit, blue dress shirt and tie, said he understood the terms of the deal and had signed it.

Prosecutor Eric Smith said afterward he could not comment due to the ongoing case against Sabrina Limon. Documents outlining the allegations against her will be filed soon, he said.

On Nov. 18, 2014, Sabrina Limon, 37, and Hearn, a former Redlands firefighter, were arrested on suspicion of first-degree murder and conspiracy to commit murder in Robert Limon's killing. Sabrina Limon was later released pending further investigation.

She was rearrested Friday in Camarillo and is being held on $3 million bail on suspicion of murder and other offenses. Her arraignment is scheduled for Tuesday.

According to court filings, Sabrina Limon told Hearn where her husband was working and his schedule on Aug. 17, 2014, the day of the killing. Robert Limon's body was found at the Burlington Northern Santa Fe Railway industrial complex in Tehachapi.

Investigators said in the filings that video surveillance captured Hearn fleeing the BNSF building just minutes after Robert Limon, 38, was shot twice in the head. Hearn disposed of evidence that investigators recovered, the filings said.

Shortly after the death of Limon, a resident of Helendale in San Bernardino County, the BNSF offered a $100,000 reward for information leading to the arrest and conviction of his killer.

Hearn and Sabrina Limon had been carrying on an affair and exchanged thousands of text messages before the killing, the filings allege. In one message, Hearn told Limon that if her husband were out of the picture, they could live their lives together.