Bill Cosby wants a judge to step down from his case days before sentencing on sex assault charges.

A defence motion on Tuesday accused Pennsylvania Judge Steven O’Neill of having a longtime grudge against a key witness in a 2016 pre-trial hearing.

The witness, ex-prosecutor Bruce Castor, said he declined the case in 2005 and promised Cosby that he could never be prosecuted over the 2004 encounter with a woman at his home.

Mr O’Neill found no evidence of a binding agreement and sent the case to trial.

Bill Cosby Emmy Awards
Actor Bill Cosby holding the Bob Hope Humanitarian Award (PA)

Cosby faces sentencing on September 24 after he was convicted of three felonies this spring.

He faces up to 10 years in prison on each count.

Mr O’Neill’s office did not immediately return a call for comment.

Camille Cosby in a separate statement called Mr O’Neill’s alleged bias in her husband’s case a “horrible injustice”.