WASHINGTON — The F.B.I. director, James B. Comey, delivered an unusually candid speech on Thursday about the difficult relationship between the police and African-Americans, saying that officers who work in neighborhoods where blacks commit crimes at a high rate develop a cynicism that shades their attitudes about race.

Citing the song “Everyone’s a Little Bit Racist” from the Broadway show “Avenue Q,” he said police officers of all races viewed black and white men differently. In an address to students at Georgetown University, Mr. Comey said that some officers scrutinize African-Americans more closely using a mental shortcut that “becomes almost irresistible and maybe even rational by some lights” because black men are arrested at much higher rates than white men.

In speaking about racial issues at such length, Mr. Comey used his office in a way that none of his predecessors had. His remarks also went beyond what President Obama and Attorney General Eric H. Holder Jr. have said since an unarmed black teenager, Michael Brown, was killed by a white police officer in Ferguson, Mo., in August.

Mr. Comey said that his speech, which was well received by law enforcement officials, was motivated by his belief that the country had not “had a healthy dialogue” since the protests began in Ferguson and that he did not “want to see those important issues drift away.”