The defendants face charges including treason, establishing a spy ring with Iranian intelligence and passing on sensitive data on military zones.
Most of the 32 are from Saudi Arabia's restive Eastern Province, with one an Iranian national and another an Afghan.
Tensions between Saudi Arabia and Iran have escalated in recent weeks.
Saudi Arabia broke off diplomatic relations with Iran in early January following the storming of its embassy in Tehran by protesters angered by the execution of a prominent Saudi Shia cleric and three other Shia.
Saudi officials insisted Sheikh Nimr al-Nimr was guilty of terrorism offences, but Iran's supreme leader said he had been executed solely for his criticism of the Sunni monarchy.
The defendants who went on trial at the Specialised Criminal Court in the capital Riyadh on Sunday were detained in 2013, Saudi media reported.
They include several well-known figures in the Shia community who are not involved in politics, including an elderly university professor, a paediatrician, a banker and two clerics, according to the Reuters news agency.
Eastern Province is home to most of Saudi Arabia's Shia Muslims. They make up less than 15% of the national population, and many claim they suffer discrimination.
Dissent is rarely tolerated in Saudi Arabia, and between 2011 and 2013 more than 20 people were shot dead by security forces and hundreds more detained.
Shootings and petrol bomb attacks also killed several police officers.

The 32-year-old Dane spent the second half of last season on loan at the Lilywhites where he made 14 outings.
Lindegaard made 29 appearances for Manchester United over five years before his move to the Baggies.
"I'm really happy that things have fallen into place before we get closer to the season," he said.
"It was a very easy decision. I could have gone to several other clubs in England but it was a no brainer, I wanted to stay here."
Find all the latest football transfers on our dedicated page.

Liam Cann, 22, of Blind Lane, Goldhanger, Essex, contacted a number of boys while playing Xbox games online, Chelmsford Crown Court heard.
He was convicted of 23 sex offences in October last year, having abused six boys from 2006 until 2014.
Judge John Dodd described the defendant as "clever and calculating".
The judge told the court that Cann, a bell-ringer at his local church, had bribed his victims "with Fifa game currency", which players can use to buy in-game features and build their teams of footballers.
Cann, who admitted one offence of possessing indecent images, was given an extended licence period of six years to remain in place after his release, and was placed on the sex offenders register for life.
His other offences included sexual grooming, attempted rape of a child under 13, and nine counts of sexual activity with a child.
A police investigation was started after one of the boys' mothers contacted the NSPCC.
One of his victims told the court he had been contacted by Cann "by messaging" and had later received a naked image of the 22-year-old.
"He gave me £20-£50 through the Xbox and I drew it on Liam's account. I knew he gave another boy £200."
Saudi Arabia has put on trial 32 people, almost all of them members of the kingdom's Shia minority, accused of spying for Iran, local media report.
[NEXT_CONCEPT]
Preston North End have re-signed goalkeeper Anders Lindegaard on a one-year deal after he had his contract cancelled at West Bromwich Albion.
[NEXT_CONCEPT]
A bell-ringer who "wheedled, connived, bullied and bribed" boys as young as eight has been jailed for 10 years for a string of sex offences.