Two men who waved Islamic State (ISIS) flags in photos and talked about throwing gay men from buildings have been arrested.

Joseph D Jones and Edward Schimenti were arrested on Wednesday on federal terrorism charges as part of an ongoing FBI sting.

As well as posing for photos holding the Islamic State flag, an undercover agent also said that one of the men, both from suburban Chicago, said gays should be thrown from buildings.

Court filings for the charges included the photos of the 35-year-old men at the Illinois Beach State Park.

Schimenti allegedly told an undercover agent that he was annoyed because of a gay person who he worked with.

He said that if Sharia law was implemented in the US: “We are putting you [gay people] on top of Sears Tower and we drop you.”

The men also posted on social media accounts, according to the filings, with beheadings by Islamic State.

A caption next to one photo from Schimenti’s Google Plus profile showed a masked man holding a knife and an IS flag.

It was captioned that if people can’t travel abroad to fight “then slaughter the pagans next to you.”

“Islamic State will control your country, matter of fact, Islam will dominate the world!!” reads another post.

A post from 2015 by Jones’ Google Plus profile was titled: “Some of the Deadly Stabbing Ways: Do not Forget to Poison the Knife.”

When asked by an undercover agent whether he thought to travel to Syria to live under Islamic State, he said: “Every night and day,” according to the filing.

The men could face maximum prison sentences of 20 years if convicted on the charges.

They had been set to appear in Chicago federal court on Wednesday before U.S. Magistrate Judge M. David Weisman.

The so-called Islamic State, often posts photos of men being thrown from buildings in the Middle East, accused of being gay.