Hasan Rasheed Edmonds was assigned to the Illinois Army National Guard Readiness Center in Joliet, llinois. (Jim Young/Reuters)

Authorities arrested an Illinois Army National Guardsman after he attempted to travel to Libya and fight with the Islamic State as well as the soldier’s cousin who was plotting to attack a U.S. military installation and kill scores, federal prosecutors announced Thursday.

Hasan Rasheed Edmonds, 22, and his cousin Jonas Marcel ­Edmonds, 29, both of Aurora, Ill., were charged with conspiring to provide material support to a terrorist organization.

FBI agents intercepted Hasan Edmonds at Chicago Midway International Airport on Wednesday evening before he was able to board a flight to Detroit and ultimately make his way to Cairo via Amsterdam.

His cousin was taken into custody without incident at his home after taking Hasan Edmonds to the airport. The two men appeared in federal court Thursday where a judge ordered them held. One of their lawyers declined to comment, while the other could not be immediately reached.

Prosecutors said Hasan ­Edmonds, a specialist in the Illinois Army National Guard, came to the attention of the FBI late last year when investigators learned that he intended to use his military training on behalf of the Islamic State.

Once Edmonds was out of the country, the FBI said, his cousin, a convicted felon, planned to attack a U.S. military facility in northern Illinois.

It’s unclear how Hasan ­Edmonds first came to the attention of the FBI, but last year an undercover agent sent him a message on Facebook, according to a criminal complaint. In response, Edmonds said he was trying to get all his “affairs in order and get my funds up for the plunge.”

“I want to make sure my affairs here are set before leaving to give my all for this deen” or faith, he said.

In January, Edmonds received another message from the undercover FBI agent, asking if he was going to Turkey or Egypt to study.

“I wish to go to Dawlah,” Edmonds said. Dawlah is used frequently to refer to the Islamic State. He later told the undercover agent he was required to support the Islamic State.

“The State has been established and it is our duty to heed the call,” he said. “Inshallah we will complete our task or be granted shahada,” or martyrdom.

Edmonds enlisted in the National Guard in August 2011. He was a supply specialist and an enlisted specialist in rank, said Lt. Col. Brad Leighton, public affairs director for the Illinois National Guard.

Explaining his military training, Edmonds said he was “no expert with our weapons but I can get the job done.”

Once Edmonds arrived in Cairo, another individual was supposed to assist him in traveling to Derna, Libya, a city controlled by the Islamic State, according to the criminal complaint.

Edwards planned to train others or conduct reconnaissance in Libya, according to the complaint.

In an e-mail exchange last month with the FBI, Jonas ­Edmonds, who used the alias “Yunus,” told the undercover agent he wanted to move his wife and five children to Mosul, Iraq, which is under the control of the Islamic State.

If he wasn’t able to obtain a passport to travel because of his prior armed robbery conviction, Jonas Edmonds was willing to stage an attack in the United States and “unleash the lion,” the complaint quoted him as saying.

Edmonds told another FBI undercover agent he would purchase assault rifles and grenades to carry out the assault against the facility where his cousin had trained. He anticipated killing between 100 to 150 people, the complaint says.

Hasan Edmonds corrected his cousin, saying a more realistic count would be closer to 120. He said he would provide a list of officers to kill and a military uniform for his cousin to wear during the attack.

Later, the cousins and an undercover agent visited the military facility.

This month, federal prosecutors in Brooklyn charged a ­47-year-old U.S. Air Force veteran with trying to join the Islamic State.

Julie Tate and Dan Lamothe contributed to this report.