When Mohamed Bailor Jalloh walked into the Blue Ridge Arsenal gun store and indoor target range in Chantilly, Va., on Friday to purchase a Bushmaster AR-15 rifle, he had no idea that his every move was being monitored by the FBI.

Jalloh, 26, spent about 10 minutes in the shop before attempting to buy the assault weapon, but he was told that he did not have the required three forms of identification to make the purchase, said Earl Curtis, the store’s owner. Jalloh told employees that he would return.

“As soon as he walked out the door, the FBI came in,” Curtis said in an interview Tuesday. Jalloh came back the next day and bought a different assault rifle for about $1,200, Curtis said. The store — following the FBI’s instructions — rendered it inoperable before Jalloh left.

Jalloh, a former member of the Virginia National Guard, was arrested Sunday and accused in federal court of plotting a domestic terrorist attack on behalf of the Islamic State, authorities announced Tuesday.

Prosecutors said Jalloh had told someone close to him that he wanted to carry out an attack in the style of Nidal Hasan, who killed 13 people in a 2009 shooting rampage at Fort Hood, Tex. He told that person he “thinks about conducting an attack all the time, and was close to doing so at one point,” according to an affidavit filed in federal court in Alexandria. In addition to the assault weapon, he had recently purchased a 9mm Glock handgun.

Authorities did not say in court papers whether Jalloh had identified a specific target or when he planned to carry out his alleged plot.

[The Islamic State’s suspected inroads into America]

Federal authorities said in the affidavit that in late March, Jalloh made his first contact with a source who was working with a now-deceased overseas co-conspirator who was a member of the Islamic State. The overseas co-conspirator encouraged the source to have an in-person meeting with Jalloh, the documents state, and when they did meet on April 9, the FBI was watching.

At that meeting, Jalloh praised Mohammad Youssef Abdulazeez, who killed five U.S. service members in Chattanooga, Tenn., last year, the documents said. And Jalloh, at one point, suggested that someone known for organizing contests for cartoons of the prophet Muhammad would make a good target.

“You have to pick a action and take it cuz time is not on your side,” he wrote to an ally, according to the affidavit.

According to court documents, Jalloh told the confidential source that he made a six-month visit to Africa last year and met with Islamic State members in Nigeria. Jalloh also told the source that he was interested in traveling to Libya to join the group there.

Jalloh purchased a Glock handgun in February but was unsuccessful in trying to buy an assault rifle in Charlotte last month, according to the documents.

In May, Jalloh told the undercover source that it was better to plan an operation for Ramadan. He also said that he knew attack operations were “100 percent the right thing,” according to the affidavit.

Although Jalloh is quoted in court documents as saying he wanted to launch an attack, he also expresses some hesi­ta­tion.

“I really want to, but I don’t want to give my word and not fulfill it,” he told the source in April. And in June, when he was asked to provide weapons for the undercover source, he indicated that he thought the planning was for next year’s Ramadan, not this year’s.

He also asked about providing money or weapons in the event that he could not carry out the attack himself, according to the documents. Authorities say that in May, he made a cash transfer of $500 to an FBI agent he believed was a member of the Islamic State.

Jalloh, a native of Sierra Leone, is a U.S. citizen. He was taken into custody by FBI special agents while driving outside his Sterling, Va., neighborhood on his way to work Sunday morning, according to the FBI. At his home Tuesday, a family member declined to comment. Neighbors said the family kept to themselves, and it was not clear where Jalloh worked.

Jalloh served as a specialist in the Virginia National Guard from April 2009 to April 2015. He was a combat engineer in the 276th Engineer Battalion, 91st Troop Command. The battalion deployed overseas during Jalloh’s tenure, but there are no records showing that he deployed with the battalion, said Virginia National Guard spokesman A.A. “Cotton” Puryear.

Jallo quit the National Guard after listening to the lectures of deceased radical Muslim cleric Anwar al-Awlaki, according to the affidavit. Moved to look up Awlaki’s lectures online after hearing the cleric referred to in the news media as a “hate preacher,” Jalloh found himself persuaded to plot violent action, the documents state.

Awlaki’s rhetoric has been linked to several terrorist attacks and plots even after he was killed by a U.S. drone strike in Yemen in 2011. Hasan developed a relationship with the cleric after hearing him lecture at the Dar al-Hijrah mosque in Northern Virginia. And Omar Mateen, who killed 49 people in a nightclub in Orlando last month, had watched videos of Awlaki.

Jalloh appeared briefly in court Tuesday. A slim but muscular man with a small beard, he spoke softly, saying only, “Yes, sir” when asked whether he had agreed to a delay in his detention hearing.

Defense attorney Ashraf Nubani said he could not comment on the case at this time. In court, he said, “We don’t expect bond to be granted in this case . . . but he deserves a fair chance.”

Jennifer Jenkins contributed to this report.