The trial has stoked pro-independence fervour in the wealthy, northeastern region of Catalonia.
The trial has stoked pro-independence fervour in the wealthy, northeastern region of Catalonia at a time of high tensions between the local separatist government and Madrid.
Shouting "independence, independence", "down with Spain's justice system" and "we want to vote," some 40,000 people gathered on a large palm tree-lined avenue next to the courthouse, many of them holding separatist red and yellow flags.
Mas, Catalan president from 2010 to 2016, and two former members of his government are accused of serious civil disobedience and misconduct for having organised a symbolic, non-binding referendum in November 2014 despite a ban by Spain's Constitutional Court, which deemed it illegal.
"Independence isn't on trial here, democracy is on trial," Mas told AFP in the courthouse.
"It's the first time that a democratic government is tried for having allowed people to vote. It's an unprecedented moment."
Speaking from Brussels where he is attending a meeting, Foreign Minister Alfonso Dastis retorted that the trial was merely a proof of the "rule of law" in Spain.
"What is on trial is an act that failed to acknowledge a Constitutional Court sentence, nothing more."
Prosecutors want Mas and his former associates banned from holding public office for nine to 10 years.
But their defence argues they were merely defending "the right to freedom of expression" of Catalans, many of whom want a say in the future of their 7.5 million-strong region.
Catalonia, a region with its own language and customs, has long demanded greater autonomy.
But in recent years, tensions with Madrid have markedly increased, as have calls for outright independence, culminating with the election in 2015 of a pro-independence government in Catalonia backed by a majority separatist parliament.
A watershed moment was in 2010, when Spain's Constitutional Court watered down a special statute awarded to Catalonia in 2006 under the Socialist government, giving it more powers.
Supporters of independence slammed what they said was "judicial harassment" and asked for a referendum similar to the one organised in Scotland in 2014.
After the Constitutional Court banned that, Mas and his associates held the non-binding vote for which they are on trial, with the help of thousands of volunteers.
More than 80 percent of those who cast their ballot in the 2014 vote did so for independence -- although just 2.3 million people out of a total of 6.3 million eligible voters took part.
Catalonia's current government has promised to hold a referendum in September -- a binding one this time, with or without Madrid's consent.
But how exactly it will go ahead is unclear, as the conservative government of Prime Minister Mariano Rajoy insists that this type of local, one-region-only referendum is unconstitutional, and has vowed never to allow an act that would risk the unity of Spain.
Last week, reports emerged in several national dailies that Madrid was considering drastic measures to stop a vote, such as closing schools where polling booths could be set up or taking control of the police, which is normally managed by regional authorities.
The government neither confirmed nor denied the reports.
Rajoy has tasked his deputy prime minister, Soraya Saenz de Santamaria, to start regular talks with Catalan authorities, but so far these have not yielded any results.
"Reconciliation is impossible because they've said 'no' to dialogue for so long," said Merce Sancho Tusef, a 68-year-old protester.
The Catalans themselves remain divided over the issue -- 44.9 percent want independence while 45.1 percent don't, according to a recent poll conducted by a Catalan public institute.
A large majority, however, wants a referendum.