SINGAPORE - Four Bangladeshi workers accused of planning to join the Islamic State group were jailed for between two and five years in Singapore on Tuesday for raising money to fund attacks in their homeland.

Muslim-majority Bangladesh has seen a spate of brutal attacks on secular bloggers and religious minorities recently, with gunmen killing 20 hostages - mainly foreigners - at an upmarket restaurant in the capital Dhaka earlier this month in an attack claimed by IS.  District Judge Kessler Soh said in handing down the sentences that terrorism presents a "threat not just to our community but the international community at large".

Court documents said the men contributed, collected or possessed funds for the alleged plot ranging from Sg$60 ($44) to Sg$1,360 to help fund a terror campaign in their country.

The four, who pleaded guilty and could have been jailed for up to 10 years, were the first to be convicted under a Singaporean law against terrorist financing.

"Terrorism financing and any act of supporting terrorism must be roundly condemned and deterred," the judge said.

Prosecutors said that while working in Singapore, mostly in construction, the four formed an organisation called the Islamic State of Bangladesh "with a view to joining ISIS", another acronym for IS, later on.

They planned to overthrow the Bangladeshi government "by means of an armed struggle in order to establish part of the caliphate in Bangladesh", prosecutors added.

Alleged ringleader Rahman Mizanur, 31, was jailed for five years. He had tried several times to join IS in Syria but could not get visas to Turkey or Algeria, court documents showed.

Two others, Miah Rubel and Mohamad Jabath Kysar Haje Norul Islam Sowdagar, were each jailed for two-and-a-half years and the fourth, Sohel Hawlader Ismail, got two years.

Bangladesh denies IS has made inroads in the country, blaming attacks on homegrown extremist groups.

The men's actions, including meeting in parks to plan and recruit, "show that the offences... were premeditated and carefully planned over a period of time", prosecutors said.

Singapore's interior ministry had earlier said that items seized from the men included manuals on bomb-making and how to use a 0.50 calibre sniper rifle, along with a list of Bangladesh government and military officials targeted for attack.

The four defended themselves during the trial as they were unable to afford their own counsel and people accused with terrorist financing do not qualify for legal aid from the state.

Speaking in court before he was sentenced, Mizanur expressed remorse and said he comes from a poor family with two children and a wife back home.

The men were among a second group of Bangladeshis rounded up in Singapore since 27 were arrested in late 2015, also over alleged plots in their homeland. All from the first group have since been deported.

Two from the second group have cases pending and two others have yet to be charged but are detained under a law which allows for detention without trial.