A black judge has refused to recuse himself from a case over a white police officer's shooting of a black man, accusing his defence lawyers of wrongly injecting race into the case.

Montgomery County Circuit Judge Greg Griffin ruled after a contentious hearing in which the defense for police officer Aaron Cody Smith argued the judge should give up the case because of a Facebook post the judge made before he was assigned the trial.

In the post, the judge complained about being stopped by police because he was he was black. Mr Griffin said he lives “in the hood” and “can't take this black skin off.”

“It comes with the territory,” he added.

Defence attorney Roianne Conner argued she wasn't claiming that Mr Griffin was biased, only that judicial ethics rules require judges to avoid even “appearances of impropriety.”

Griffin didn't buy the arguments, saying: "It troubles me because y'all put race in it."

Smith, 24, is charged with murdering Greg Gunn, 58, on 25 February 2016. The confrontation began when the officer stopped Mr Gunn, who was walking through his neighbourhood shortly after 3am.

Friends said Mr Gunn was walking home from a weekly card game and was shot next-door to the house he shared with his mother.

The defence has said Smith stopped Mr Gunn because he thought he was acting suspiciously, and that he fought with the officer before the shooting.

In a Facebook post two weeks after Mr Gunn's death but before he was assigned the case, the judge wrote that he had been stopped by officers who claimed he matched the description of a man seen in the area with a crowbar.

The post, which did not mention the police shooting, said in part: “It was aggravating to be detained when the only thing I was guilty of was being a black man walking down the street in his neighbourhood with a stick in his hand.”

Ms Conner said many of the 239 people who commented on Mr Griffin's post compared what happened to him to Mr Gunn's killing, but the judge rejected the argument.

“This is not a stop-and-search case. This is a murder case,” said Mr Griffin, noting that the officer who first stopped him was black.

The hearing wasn't the first time the defence has raised race as an issue in the case. In a motion filed in December asking a court to move the trial outside Montgomery, the defence portrayed the officer as a victim of racial prejudice.

The city, which is about 57 per cent black, has been “infested with racial prejudice and hatred” toward Smith because of community leaders and media reports that highlighted the race of those involved, said the motion.

Race has been used as “ammunition” against the white officer, the defence claimed.

Prosecutors are opposing the defence request to move the trial, which is not yet scheduled.

Associated Press