A U.S. citizen who kept an Islamic State flag and a cache of weapons in his New York City apartment was sentenced Friday to 22 years in prison after pleading guilty to providing material support to the terrorist group, the Justice Department announced.

Sajmir Alimehmeti, a 26-year-old Albanian turned U.S. citizen, was sentenced Friday by U.S. District Judge Paul A. Engelmayer, who called him a "ticking time bomb." He called the Bronx man's conduct "terrifying."

In February 2018, Alimehmeti admitted providing material support to the group.

Alimehmeti, a onetime plumbing assistant who had studied funeral services, was arrested in May 2016 on evidence assembled over eight months by two undercover New York City police officers and an undercover FBI employee posing as ISIS recruits.

The man started collecting weapons such as combat knives that could be used in a "lone-wolf" style terrorist attack, investigators said.

SAUDI STUDENT WATCHED MASS SHOOTING VIDEOS DURING DINNER PARTY BEFORE FLORIDA NAVAL BASE ATTACK

Arresting agents reported recovering terrorist propaganda, the flag and images of jihadist fighters.

Alimehmeti had traveled overseas to support ISIS’ terror campaign by buying military-grade weapons and helping another recruit get travel documents, equipment and encryption technology to fight with the group in Syria, U.S. Attorney Geoffrey S. Berman said in a news release.

CLICK HERE TO GET THE FOX NEWS APP

"Even after his incarceration, Alimehmeti continued his supportive conduct for ISIS by working with convicted Chelsea bomber Ahmad Khan Rahimi, to distribute ISIS propaganda in prison," Berman said.

In addition to 22 years in prison, Alimehmeti also was sentenced to five years supervised release, the DOJ said.