A Singapore court has sentenced four Bangladeshi workers to jail terms of up to five years for allegedly planned attacks linked to the Islamic State group in their own country.

Prosecutors said the men, who pleaded guilty, had contributed part of their salary to buy food, arms and weapons like knives and pistols to launch attacks in Bangladesh.

The Ministry of Home Affairs has said the group's suspected leader, Rahman Mizanur, possessed guides on making weapons and bombs.

In sentencing Rahman to five years in jail on Tuesday, District Judge Kessler Soh emphasized that a deterrent sentence and "much stiffer punishment is warranted." He ordered the other three men to be jailed between two and 2 ½ years.

The four men are part of a group detained since April.