A flag of the Islamic State. AFP PHOTO/JM LOPEZJM LOPEZ/AFP/Getty Images (JM LOPEZ/AFP/Getty Images)

A 24-year-old resident of Maryland was charged with attempting to provide material support to the Islamic State by planning to kill a member of the U.S. military, federal officials said Monday.

Federal agents picked up on the alleged plans of Nelash Mohamed Das — a citizen of Bangladesh living in Hyattsville — and placed him under surveillance.

At one point, a confidential source provided Das with a gun, and on Sept. 30, he arrived at the Maryland address where he had been led to believe his target lived, according to federal officials.

At the time, “Das believed that the firearms could fire ammunition; in reality, they had been rendered inert by the FBI,” federal officials said.

Das was taken into custody there after a short chase.

Earlier, from September 2015 to early 2016, Das had used social media to express his support for the Islamic State, including support for terrorist attacks in Paris and San Bernardino, Calif., according to federal officials.

“Sitting on twitter is not enough,” he allegedly wrote on Sept. 28, 2015. “I envy seeing brothers getting shahada n slaying kuffar while im at home not gettin any action.”

“Shahada,” according to the FBI, translates roughly to “dying as a martyr,” and “kuffar” means “infidels” or “disbelievers.”

In January, Das allegedly tweeted a picture of an AK-47 assault rifle along with the text: “This is more than just a gun. This is a ticket to Jannah.”

Jannah, the FBI said, is a reference to the Islamic concept of paradise.

It was unclear Monday evening whether Das had retained an attorney in the case or what account Das has offered of the alleged events. Das had a court appearance in court Monday and was ordered detained until a hearing set for Thursday. He faces up to 20 years in prison.

In a seven-page criminal complaint, federal agents said that on April 30, Das attended a handgun qualification license class at a firing range in Prince George’s County. After class, according to the complaint, he told another person he wanted to buy a Glock 9mm handgun and an AK-47.

Das returned to the range seven times to practice firing weapons from June to September, according to the complaint.

“The danger posed by Mr. Das during this investigation was very real. He was committed to carrying out an attack against a military member,” said Special Agent in Charge Gordon B. Johnson of the FBI’s Baltimore Division in a statement announcing the charge.

According to an affidavit filed by federal officials, Das was admitted to the United States in 1995 and is a legal permanent resident.

“Our goal is to catch dangerous suspects before they strike, while respecting constitutional rights,” said U.S. Attorney for Maryland Rod J. Rosenstein.

To catch Das, agents used a confidential source who supplied Das with what Das thought was an address of a member of the U.S. military. Last Wednesday, the two drove to the address purportedly to conduct surveillance. On Friday, the day of the planned attack, Das allegedly sent a text to the informant saying: “I’m ready.”

The confidential source picked up Das, and Das loaded ammunition into the inoperable firearm, according to federal officials. It was a short time later, at the fake address, that the FBI moved in on him, according to the criminal complaint.