A Saudi court has sentenced four people to jail terms for trying to go to Iraq to join fighting there and for supporting al-Qaeda's operations abroad, state news agency SPA has said.

The four, one of whom was sentenced in absentia, were given prison sentences of two years to five years and six months on Monday, SPA said. They were also banned from travel for specific periods.

Other charges against the defendants included "storing and possessing prohibited computer documents and helping a number of people in going abroad to fight in troubled nations," the agency said.

In February, Saudi Arabia said it would jail for up to 20 years any citizen who fought in conflicts abroad, in an apparent effort to deter Saudis from joining rebels in Syria and becoming a security risk on their return.

The latest verdicts show that Riyadh is also worried about Saudis who may want to join the fighting in Iraq, where an al-Qaeda offshoot captured swathes of Iraqi territory last month, the Reuters news agency reported.

The decree in February also said Saudis who join, endorse or give moral or material aid to groups it classifies as terrorist or extremist organisations, whether inside or outside the country, would face prison sentences.

Earlier this year, Riyadh designated the Islamic State in Iraq and the Levant as a terrorist group. ISIL has renamed itself the Islamic State and proclaimed the establishment of a "caliphate" on land it has captured in Syria and Iraq.