Image copyright EPA Image caption Akhror Saidakhmetov (far left) and Abdurasul Juraboev (far right) appeared in court

The FBI has arrested three foreign nationals living in Brooklyn who agents say sought to join the Islamic State.

Two of the men had threatened to kill police officers and FBI agents in the US if they were unable to travel to Syria, the FBI said.

The men came to the authorities' attention after they posted to Uzbek-language websites in recent months.

In one post, they pledged to kill US President Barack Obama, the FBI said.

Abdurasul Juraboev, 24, and Abror Habibov, 30, both of Uzbekistan; and Akhror Saidakhmetov, 19, of Kazakhstan, were charged with conspiracy to provide material support to a foreign terrorist organisation.

The defendants violated the true tenets of their faith in pursuit of their radical, violent agenda Diego G Rodriguez, FBI

Mr Saidakhmetov was arrested at John F Kennedy International Airport in New York on Tuesday, as he tried to board a flight to Istanbul, Turkey.

Mr Juraboev bought a plane ticket to travel from New York to Istanbul next month, federal prosecutors said.

The third suspect, Mr Habibov, is accused of helping to fund Mr Saidakhmeto's efforts to join the Syrian jihadists, prosecutors said.

"This is real," William Bratton, commissioner of the New York Police Department, said on Wednesday.

"This is the concern about the lone wolf, inspired to act without ever going to the Mideast."

The US has charged about 20 people with planning to join militant groups overseas, many intending to go to Syria to fight with Islamic State (IS).

FBI said Mr Saidakhmetov had worked for Mr Habibov, who operates mobile-phone repair stands in malls in several cities.

"I am in USA now but we don't have any arms. But is it possible to commit ourselves as dedicated martyrs anyway while here?" Juraboev wrote on the Uzbek-language website, according to the court papers.

"What I'm saying is, to shoot Obama and then get shot ourselves, will it do? That will strike fear in the hearts of infidels."

Image copyright EPA Image caption Two of the men were arraigned in New York on Wednesday

Mr Saidakhmetov told an FBI informant that he planned to go Syria but he would still carry out attacks if he was unable to go.

"We will go and purchase one handgun ... then go and shoot one police officer. Boom ... Then we will go the FBI headquarters, kill the FBI People," Saidakhmetov told the informant.

If convicted, each defendant faces a maximum sentence of 15 years in prison.

"The defendants violated the true tenets of their faith in pursuit of their radical, violent agenda," said Diego G Rodriguez of the FBI's New York Field Office.

Figures suggest more than 20,000 foreigners have joined the conflicts in Iraq and Syria in the last three years, with as many as 4,000 from Western Europe.

This week, UK police said three missing London teenagers flew to Turkey to join Islamic State militants. It is believed that they have now crossed into Syria.

"The flow of foreign fighters to Syria represents an evolving threat to our country and to our allies," US Attorney General Loretta Lynch said, announcing the arrests.