A flag of the Islamic State. (Agence France-Presse via Getty Images)

In the spring of this year, Mohamed Bailor Jalloh said he often thought about carrying out an attack to support the Islamic State. The Northern Virginia man drew inspiration from Nidal Hasan, the Army major who killed 13 people at Fort Hood, Tex., in 2009.

But Jalloh, a former member of the Virginia National Guard, also questioned whether he could “ensure his heart would be strong and not fail him” during an attack, court records show. If he could not take part in an operation, he suggested, he could help by providing money or weapons.

Jalloh, 27, pleaded guilty Thursday in federal court in Virginia to attempting to provide support to the terrorist group. Court records show that the case came together largely because one person Jalloh was communicating with was an FBI source.

Jalloh, who was born in Sierra Leone, lived in Loudoun County and was a U.S. citizen. His family has declined to comment, and neighbors said they kept to themselves. Authorities have said Jalloh had a job at the time of his arrest in July but did not say where.

It was on a 2015 trip to his native country that Jalloh came into online contact with a member of the Islamic State, according to prosecutors.

Jalloh traveled to Niger, where he boarded a truck to Libya with plans to join the terrorist group. But he backed out, later saying he was not ready to fight.

Around January, just before returning from his six-month trip, Jalloh began communicating online with Abu Sa’ad Sudani, a now-deceased Islamic State member who was plotting an attack in the United States.

In April, according to court papers, Sudani asked Jalloh if he wanted to “[join] the brothers for the operation.”

“I really want to, but I don’t want to give my word and not fulfill it,” Jalloh told Sudani. Another time, he said, “I just want to live a good Muslim life and die as a shaheed,” or martyr.

Jalloh bought a Glock handgun in February and said that committing an attack was “100 percent the right thing.” He also said participating was a test and was not supposed to be easy.

In May, during a conversation with the undercover FBI source he had met through Sudani, Jalloh said it would be best to plan an attack for Ramadan and also said he could offer more financial support.

Jalloh had already sent money to the organization, once in March and a second time in April. He transferred a total of more than $700 to a family member living in Sierra Leone, who then sent the money to one of Sudani’s associates.

In mid-May, the FBI source told Jalloh about a plot to murder U.S. military personnel and asked Jalloh about acquiring weapons. Jalloh began searching online for weapons in June and traveled to North Carolina, where he visited a family member and unsuccessfully attempted to purchase an AK-47.

On July 1, Jalloh attempted to buy an AR-15 at a Northern Virginia gun shop but lacked proper identification, according to court records.

The next day, he searched the Internet for “Orlando shooting weapon” and then bought a Stag Arms AR-15 from the shop. But the FBI had been watching, and the gun was rendered inoperable.

Jalloh was arrested July 3.

In a statement, Dana J. Boente, U.S. attorney for the Eastern District of Virginia, praised the work of the FBI and said that “Jalloh attempted to help facilitate what he believed would be a terrorist attack here in Virginia.”

Jalloh’s attorney, Joseph Flood, declined to comment Thursday. During a plea hearing, he said that although Jalloh admitted to the charges, he planned to “provide more context” later.

Jalloh served as a specialist in the Virginia National Guard from April 2009 to April 2015. A Virginia National Guard spokesman has said there are no records showing that Jalloh was deployed overseas.

Jalloh is set to be sentenced in January and faces a maximum penalty of 20 years in prison