You are not permitted to download, save or email this image. Visit image gallery to purchase the image.
Fabjan Alameti (21) appeared before a US magistrate judge on Thursday on charges of possession of a firearm by an unlawful user of a controlled substance and making false statements involving international and domestic terrorism.
US Magistrate Judge Jeremiah Lynch ordered him to be detained for further proceedings.
Alameti's federal public defender, John Rhodes, said he is working on a proposal for his client's release. He declined further comment.
Authorities first interviewed Alameti in 2018, and he later made pro-ISIS comments on Facebook, FBI Special Agent Matthew Duermeier said in a sworn statement filed with the court.
Starting in January of this year, Alameti spoke with a federal informant about fighting with the terrorist organisation in Iraq and Syria and plotting an attack in the US against a military facility, recruitment centre, government building, "gay club" or Jewish temple, Duermeier said.
But Alameti also later said he would not carry out an attack on US soil because the country had granted him citizenship, the FBI agent's statement said.
Alameti told the informant he moved from his home in the Bronx to Bozeman last month because he hated his life in New York City, was having family issues and had a job interview in Montana, where it was easier to buy a gun, Duermeier said.
Alameti was travelling to Montana by bus on March 15 when 50 people were killed at two mosques in Christchurch, New Zealand.
He asked the federal informant to send him a link to the video of the shooting because it would fuel him.
"I will attack random people to avenge the blood," Alameti told the informant, according to Duermeier.
Once in Bozeman, Alameti looked at guns in pawn shops and Wal-Mart, and he bought an air rifle.
He was kicked out of a hotel for smoking marijuana and hospitalised on March 25 for apparent acute alcohol intoxication, Duermeier said.
After he was released, he went to the Bozeman police department to pick up his belongings, where was interviewed by an officer.
In that interview, Alameti denied being linked to anyone who asked him to travel overseas, said he never expressed a desire to harm Americans, never expressed a desire to fight the US military overseas and never expressed a desire to fight for ISIS, Duermeier said.
On Tuesday, another federal informant recorded Alameti saying while buying marijuana that he could die the following day and said he wanted to "shoot up" the hotel that he had been kicked out of.
He said he wanted to go to a gun range the following day and shoot a rifle that he had seen in a pawn shop, the FBI agent's statement said.
On Wednesday, Alameti showed up at the firing range, paid $US35 ($NZ51) to rent an M1A rifle and was arrested when he took possession of it, Deurmeier said.
The federal charge on which he was arrested says it is illegal to possess a weapon while using drugs, and the false statement charge apparently is related to the answers he gave Bozeman police during his interview.