An 18-year-old from Maine and two underage teenagers planned an ISIS-inspired attack on a Chicago-area Shia mosque that would have been carried out at the end of March, the FBI said in court documents unsealed on Friday. 

Xavier Pelkey and an unnamed 17-year-old and 15-year-old from Kentucky and the Chicago area communicated through Instagram and other chat applications and planned an attack on a specific mosque in late March during "spring break," the newly released documents said. 

Pelkey was arrested on Feb. 11 and charged with possession of an unregistered destructive device. 

Under the plan, Pelkey was supposed to bring firearms and ammunition to Chicago and he allegedly told one of his coconspirators that he had made an explosive device to "get more people." 

RELEASED ALBUQUERQUE DOUBLE MURDER SUSPECT EXEMPLIFIES 'ROOT OF VIOLENCE, IN NM CITY, POLICE SAY

FBI investigators allegedly found a hand painted ISIS flag in the bedroom of suspect Xavier Pelkey. 

FBI investigators allegedly found a hand painted ISIS flag in the bedroom of suspect Xavier Pelkey.  (FBI)

Pelkey and the other teen who lived outside of Chicago were to take a train or a bus and allegedly meet their fellow coconspirator in the city before the attack. 

One of the teens "explained that they would enter the Shia mosque and separate the adults from the children, then murder the adults," the court documents said. "If they had not encountered law enforcement at that point, they would continue on to another Shia mosque or Jewish synagogue and execute the same plan. They did not have a plan to escape but rather their plan ended with them being shot by law enforcement."

A second flag was found in Pelkey's bedroom. 

A second flag was found in Pelkey's bedroom.  (FBI)

Chicago FBI agents seized multiple firearms, including a Remington pump shotgun, swords, knives, a bow and arrows, multiple homemade ISIS flags, and multiple electronic devices from the 15-year-old's home following a search warrant, the FBI said. 

While speaking to the FBI, the 17-year-old said Pelkey "had talked about gathering materials to make fireworks to attack someone," adding that he "told him that he wanted Allah to grant him to be a shaheed and die while fighting in the cause of Allah."

Pelkey allegedly admitted to the FBI to owing the Instagram account "Abdullah.ibn.ahmad" that he used to communicate with his conspirators after the FBI was given access to the account by Meta, which owns Instagram, the documents said. 

CLICK HERE TO GET THE FOX NEWS APP

While conducting a search at Pelkey’s home in February agents allegedly found three homemade explosive devices in his bedroom and two hand-painted ISIS flags.