Citizens of Saudi Arabia who fight in conflicts outside the kingdom could receive prison sentences ranging from three to 20 years in jail.
Saudi king Abdullah Bin Abdul Aziz issued a royal decree on Monday, which says that any Saudi citizen who join "extremist religious and ideological groups, or those classified as terrorist organisations".
Supporting such groups, adopting their ideology or promoting them "through speech or writing" would also incur prison sentences, the decree added
The decree appeared aimed at stemming the flow of Saudi fighters going to Syria, which is believed to have drawn hundreds of young Saudis, and has worried some in the kingdom that fighters could return radicalised.
Foreign fighters in Syria
The decree said it is the Saudi government's duty to block actions and language that harm public security and stability by exposing the nation to danger and "damaging the status of the kingdom" Islamically, internationally and among Arabs.
The jail terms increase to five to 30 years for members of militaries who serve as officers.
Many young Saudi men appear to have been encouraged to join the fight in Syria.
The uprising against President Bashar al-Assad has transformed into a regional proxy war between Iran and Saudi Arabia, which support opposing sides. Foreign fighters have infiltrated the opposition, triggering infighting that has undermined the rebellion.
Saudi officials and key high-level Muslim leaders have largely spoken out against young Saudis joining the fight.
While the Saudi government backs some rebel opposition groups in Syria with weapons and aid, officials say Riyadh does not fund al-Qaeda-linked groups.
The royal decree was issued only two days after a sweeping new anti-terrorism law went into effect.