The men were actually cooperating with the federal authorities, the department said, and the plan never presented any danger to the American public or members of the armed forces. Mr. Elfgeeh has remained in custody in Rochester since his arrest.

The authorities said that in the last year Mr. Elfgeeh had taken “several steps to prepare the men for the trip,” including sending $600 to a person in Yemen to assist the men in traveling to Syria from Yemen.

Mr. Elfgeeh told one of the men that he was thinking about getting a gun, ammunition and a bulletproof vest and would “just go around and start shooting,” the Justice Department said. Later, Mr. Elfgeeh gave the man $1,050 in cash to buy two handguns with silencers. In May, Mr. Elfgeeh was given the weapons and was then arrested by the Rochester Joint Terrorism Task Force.

At the time of his arrest, Mr. Elfgeeh was charged with illegally receiving and possessing unregistered firearm silencers. The allegations in the indictment unsealed on Tuesday are considerably more serious, reflecting the Justice Department’s determination to “use all available tools to disrupt and defeat” the Islamic State, said William J. Hochul Jr., the United States attorney for the Western District of New York.

Attorney General Eric H. Holder Jr. added: “We will remain aggressive in identifying and disrupting those who seek to provide support to ISIL and other terrorist groups that are bent on inflicting harm upon Americans. As this case shows, our agents and prosecutors are using all the investigative tools at our disposal to break up these plots before individuals can put their plans into action.