Three militia members plotted to detonate a bomb at a housing complex in western Kansas where Somali immigrants lived and worshiped, federal investigators said Friday.

The men, who were arrested Friday morning on domestic terrorism charges, scouted out the apartments in Garden City, Kan., stockpiled guns and composed a manifesto about their anti-Muslim motives, prosecutors said.

“Their rhetoric and their speech have revealed a hatred for Muslims, Somalis and immigrants,” an F.B.I. agent wrote in affidavit related to the case.

The plotters planned to carry out their attack on Nov. 9, the day after the presidential election, the authorities said.