DETROIT — A 19-year-old man was arrested after spending months planning an attack against a U.S. Army site in suburban Detroit on behalf of the Islamic State group, authorities said Wednesday.

Ammar Said was planning to have another person commit a mass shooting at the Army’s Tank-Automotive & Armaments Command in Warren, but he didn’t know that two supposed allies were undercover FBI employees keeping track of every step, the government said.

Investigators recorded audio and video images of their meetings with Said, including handwritten diagrams of the site, which is known as TACOM and the Detroit Arsenal.

Said, a recent member of the Michigan Army National Guard, was arrested Tuesday shortly after launching a drone for a final look before an attack, the FBI said in a court filing.

“Helping ISIS or any other terrorist organization prepare or carry out acts of violence is not only a reprehensible crime — it is a threat to our entire nation and way of life,” U.S. Attorney Jerome Gorgon Jr. said.

The FBI said Said planned to send one of the undercover agents into TACOM with Molotov cocktails and assault-style weapons.

The other undercover operative told Said that he would “be on the first plane to Syria” after an attack.

Said, a Detroit-area resident, appeared in court Wednesday on charges of attempting to provide material support to a terrorist organization and distributing information related to a destructive device. He agreed to remain in custody without bond.