A British man accused of butchering a Chicago hairstylist as part of a twisted sexual fantasy with a Northwestern University professor has accepted a plea deal and will testify against his co-defendant in exchange for a 45-year prison sentence, prosecutors said.

Andrew Warren, a onetime Oxford University financial officer, was set to go on trial next week alongside his co-defendant — former Northwestern microbiology professor Wyndham Lathem — in the July 2017 stabbing death of Lathem’s boyfriend, 26-year-old Trenton James Cornell-Duranleau.

But Warren, 58, agreed Monday to plead guilty in the horrific slaying of Lathem’s boyfriend, who was nearly decapitated and found stabbed 70 times at the professor’s apartment in Chicago.

“‘Tis true,” Warren said, when asked if his confession was genuine, the Chicago Tribune reported.

Prosecutors in Cook County have said Warren and Lathem, 44, chatted online for months prior to the killing and ultimately plotted to kill Cornell-Duranleau before taking their own lives, according to the outlet.

Warren also agreed to testify against Lathem, who has pleaded not guilty in the slaying. His trial date has not yet been set, the newspaper reports.

Warren signed a written plea agreement, but a judge kept details of the deal sealed until he could meet with Lathem’s attorneys next week when the former Northwestern professor is scheduled to return to court.

A judge also issued a gag order on attorneys in the case, barring them from discussing the high-profile killing that led to a nationwide manhunt before Lathem and Warren were arrested in California. Both remain held without bail in Chicago.

Lathem lost his post at Northwestern after he fled Chicago, while Warren was suspended from his job as a financial officer at Somerville College, which is part of the University of Oxford system.

Prosecutors said Monday that Lathem began the planned attack by stabbing Cornell-Duranleau as he slept, while Warren restrained him and struck him with a lamp while stabbing him, the Chicago Sun-Times reports.

The pair had planned to kill themselves after Cornell-Duranleau, but instead fled the apartment and started a two-week road trip that included stops at a public library where they made large donations in the victim’s name, prosecutors said.