A federal judge signed off on a deal Wednesday to give a one-year prison sentence to a former Philadelphia police officer who confessed to the violent sexual assault of a woman in his squad car three years ago.

But as he approved the punishment worked out between prosecutors and ex-cop Thomas O’Neill, 53, U.S. District Judge Juan R. Sanchez said he did so while essentially holding his nose.

“Quite frankly, I have real trouble with this plea,” the judge said. “This is an extraordinarily troubling case, because the conduct here is extraordinarily reprehensible and incomprehensible.”

Prosecutors said they weren’t exactly thrilled about O’Neill’s relatively light term of incarceration, given that he abused his position to order a woman into his police car, drive her to an isolated spot, handcuff her, and assault her for more than an hour while brandishing his service revolver and a knife.

But the Philadelphia District Attorney’s Office had declined to prosecute the case, and the U.S. Attorney’s Office had limited ability to intervene, because state lines were not crossed and the victim was not a minor, Assistant U.S. Attorney Michelle Morgan said.

Still, she added, federal prosecutors were able to charge O’Neill with civil rights violations and to extract a guilty plea, thereby sparing the victim the prospect of reliving her experience on the witness stand during a trial.

“Given the limitations of what we could charge and what we could accomplish in this case, we feel that this was the best possible outcome,” Morgan told the judge. “The victim can know that this defendant has been convicted for this crime, that he is being held accountable, that he will lose his pension, and that he will face incarceration.”

O’Neill, a 24-year veteran of the force until he resigned in 2016 as a result of the investigation that brought his misconduct to light, made few excuses.

Turning to his victim, seated in the front row of the Philadelphia federal courtroom with her mother and fiancé, he quietly apologized and said he was intoxicated at the time of the attack.

“I have shamed this woman, myself, my wife, my family, my colleagues from the department,” he said. “I have … besmirched the title of ‘police officer.’”

The woman, identified in court only by her initials because she was the victim of a sexual assault, did not address the judge when offered the opportunity. Instead, her lawyer, Gregg L. Zeff, told Sanchez she supported O’Neill’s one-year sentence, if only so she wouldn’t have to testify.

She came forward within days of her attack and told Internal Affairs that she first met O’Neill when he responded to a robbery call at her apartment building before her attack.

When he spotted her riding her bike at dusk on July 3, 2016, he pulled up his squad car and ordered her inside.

O’Neill handcuffed her and drove her to the parking lot of Northeast High School on Summerdale Avenue in Rhawnhurst, and assaulted her inside and outside the vehicle. For much of that time, she alleged, O’Neill pressed his service weapon against her inner thigh and forced her to touch it.

In a lawsuit filed in 2016, the accuser, a white woman now in her late 30s, also alleged that O’Neill, who is also white, made racially charged comments, saying he fantasized about beating, raping, and “shooting a n—” in the head. He also described having sex with other women he had picked up in his squad car.

“You should be outraged,” the woman’s lawyer, Zeff, told the judge Wednesday, after Sanchez called the deal troubling. She "will spend the rest of her life dealing with this — not just her sexual assault, but the violation of her trust and faith in the police system.”

O’Neill admitted much of that misconduct as soon as he was confronted with the allegations by Internal Affairs in 2016. The attack was at least partly caught on video, Morgan said Wednesday, and forensic examiners found his DNA on the victim’s shorts.

It remained unclear Wednesday why then-District Attorney Seth Williams’ office chose not to prosecute in 2016. A spokesperson for District Attorney Larry Krasner declined to comment, noting the decision was made by a prior administration.

The FBI and federal prosecutors became involved after the victim filed her lawsuit against O’Neill and the city.

“Securing a guilty plea from this defendant and ensuring that he serves time in prison was a priority for my office in seeking justice in this case,” said U.S. Attorney William M. McSwain.

A conviction on state sexual assault charges could have resulted in maximum prison sentences of 10 or 20 years. The federal charge to which O’Neill pleaded guilty in January — deprivation of rights — also carries a maximum 10-year sentence.

But the sentencing guidelines for the former officer’s crime suggested a 12-to-18-month prison term based largely on his acceptance of responsibility and lack of a criminal record.

O’Neill has been punished in other ways, his attorney Lloyd Long III said. His wife has divorced him. He has no custody of his 16-year-old daughter and is only able to speak to her once a month.

He will also lose his pension and has gone from earning $90,000 a year as a police officer to making $7.25 an hour at a Burger King. He remains in treatment for alcoholism and in therapy after expressing suicidal thoughts.

In addition to his prison sentence, O’Neill was ordered Wednesday to pay a $7,000 fine and to complete three years’ probation, during which he will have to participate in sex offender, alcohol, and mental health treatment programs.

He also faces the prospect of additional financial penalties from the lawsuit his accuser filed against him and the city. That case, filed in Common Pleas Court, had been placed on hold while his prosecution played out.

Before he was led from the court in handcuffs Wednesday, O’Neill told both the judge and his victim he was desperate to atone in any way he could.

“I have weakness of character, but I am at core a person who can better himself,” he said. “I want to be rehabilitated. … I want to be the moral person I was long ago.”