The convicted, according to state-owned TV Al Ekhbariya, were trained in camps in Iran and were tasked to eliminate prominent figures in the kingdom.
The court ruling did not give further details on the men.
Saudi Arabia over the past has handed heavy sentences to individuals it regards as proxies of its regional arch adversary, the Islamic Republic of Iran.
Fifteen people were sentenced to death in late 2016 for spying for Iran. Shia minority in the kingdom have been associated to Shiite Iran.
The beheading of top Shia cleric Nimr al-Nimr in the kingdom in early 2016 fueled tension between Riyadh and Tehran, with thousands of Iranians attacking Saudi foreign missions in Iran.
Both powers have been opposed in regional countries namely Yemen, Syria and Lebanon where they back opposed sides.
This week, Iranian supreme leader Ayatollah Ali Khamenei indicated that Tehran will continue to support “oppressed nations” as response to western powers’ demand to the Islamic Republic to curb its regional influence; a condition to lift economic sanctions re-imposed by President Donald Trump after walking away early last month from the 2015 nuke deal.