A retired Philadelphia police officer has been charged with civil rights violations for allegedly sexually assaulting a woman while on duty more than two years ago, federal prosecutors announced Wednesday.

Thomas O'Neill, 47, is accused of assaulting the woman inside his squad car on July 3, 2016, court documents show. The woman, who is black, claims the officer, who is white, rubbed his gun on her body during the alleged assault and made racist remarks, according to an indictment unsealed Wednesday.

O'Neill, who retired in September 2016, was indicted with deprivation of rights under color of law. He would face up to 10 years in prison if convicted.

The charges stem from claims outlined in a civil lawsuit filed by the unidentified woman against O'Neill and the city in 2017. That lawsuit is still pending in Common Pleas Court.

"No matter who you are, if you commit a violent crime, we are committed to holding you accountable and keeping our community safe," U.S. Attorney William M. McSwain said in a news release.

O'Neill's attorney, Nicholas Cummins, declined to comment on the charges.

In an interview Wednesday, John McNesby, president of Fraternal Order of Police Lodge 5, called it a "sad story" and indicated O'Neill would be unable to count on support from the union.

"If what they're saying is true, that's a horrendous crime," McNesby said. "It is what it is. He's on his own."