Two men who planned terror attack in Sydney were sentenced to 20 years imprisonment on Friday, a local media reported.

Omar Al-Kutobi, 25, and Mohammad Kiad, 27, both pleaded guilty to preparing for and planning a terrorist act after purchasing knives and posing for photos in front of an Islamic State flag.

It said that they posed for the photo in a flat they shared in western Sydney in February 2015.

Police believed an attack was imminent and found videos containing threats to stab and kill with the men saying “we are the soldiers of the Islamic State; we are here to cut your heads’’.

It reported that in a rare live televised judgement, Justice Peter Garling told the court the two men planned to attack a Shiite prayer hall in Sydney’s west with explosive material.

Report says they will have to serve 15 years in jail before they will be eligible for parole.

The Australian government recently introduced a new law allowing authorities to keep convicted terrorists in jail after their sentence is completed if they are still considered to be a threat to the community.