In the end, Andrew Warren wanted a chance to avoid dying in an American prison.

Warren, a 58-year-old British citizen, reached a plea agreement this week with Cook County prosecutors, admitting his role in the murder of 26-year-old Trenton James Cornell-Duranleau.

Warren agreed to a 45-year prison sentence in exchange for damning testimony against his former co-defendant, former Northwestern microbiologist Wyndham Lathem.

Details of the plea deal unsealed this week show prosecutors also agreed not to challenge Warren if he asks the U.S. Department of Justice to send him back to his native England. Police said Warren flew to the U.S. for the first time when he came to Chicago just days before he joined Lathem in the brutal stabbing of Lathem’s boyfriend — Cornell-Duranleau — inside Lathem’s River North apartment on July 27, 2017.

The return to England could cut Warren’s sentence nearly in half, under U.K. rules granting prisoners credit for good behavior. But there is no guarantee U.K. authorities would welcome Warren back following his guilty plea and sentencing here.

Warren will not be formally sentenced until after Lathem’s trial.

Warren had faced 20 to 60 years in prison, according to his plea deal. Warren has been jailed since surrendering in California after nearly two weeks on the lam with Lathem.

According to the plea deal, prosecutors already had a strong case against Warren, who had given a videotaped confession to police after his arrest. Court records indicate Warren will testify that he began corresponding with Lathem online a month before flying into Chicago. Three days later, he went to Lathem’s apartment, where the world-renowned microbiologist allegedly outlined a plan to fatally stab Cornell-Duranleau, who was sleeping in a bedroom, while Warren filmed the murder. Warren also admitted to covering Cornell-Duranleau’s mouth and holding him down as Lathem stabbed him, and to hitting him in the head with a lamp, then stabbing him in the chest, authorities said. Police said Cornell-Duranleau was stabbed dozens of times.

Warren had opted to be tried separately from Lathem, and his statement would have been inadmissible as evidence against Lathem. By agreeing to testify against Lathem, he can provide an eyewitness account of the gruesome killing, though Lathem’s lawyers said this week they are eager to cross-examine Warren.

Warren and Lathem fled the city in a rented car, and police have said Lathem sent friends and family plaintive messages confessing to the murder. The pair stopped at a public library in Lake Geneva, where they donated $1,000 in Cornell-Duranleau’s name, and also donated more than $5,000 to a men’s health center in Chicago. Days later, after negotiating with police, Lathem dropped Warren off at a police station in San Francisco, then surrendered to police in nearby Oakland.