WASHINGTON — An Ohio man who had hoped to ally himself with the Islamic State was arrested Wednesday in connection with a planned attack on the United States Capitol, federal authorities said.

Christopher Lee Cornell, 20, of Green Township, near Cincinnati, was charged with attempting to kill a federal officer and with possession of a firearm with the intent to commit a violent crime.

Mr. Cornell drew the attention of the authorities during the summer after he used a Twitter account under the name Raheel Mahrus Ubaydah to express support for terrorist groups and to make threats against members of Congress, according to a criminal complaint filed in Federal District Court in Ohio.

In a series of conversations with an F.B.I. informant, Mr. Cornell claimed that he was in contact with terrorist groups overseas, but said he would not wait for authorization before waging an attack, the F.B.I. said.