Artur Mas, the former leader of Catalonia, was banned on Monday from holding public office, after being found guilty of disobeying a Spanish court when his government staged a nonbinding independence vote in Catalonia in 2014.

The court ruled that Mr. Mas should be banned from holding public office for two years, as well as fined 36,500 euros, nearly $39,000, for organizing the 2014 vote even after Spain’s constitutional court had ordered that the vote be suspended. The prosecution had sought a 10-year ban.

The ruling against a former regional government leader comes during an intense territorial conflict over Catalonia. The current political leadership of Catalonia has vowed to hold an independence referendum later this year — this time, a binding one — despite the strenuous objections of the conservative government in Madrid.

Spain’s judiciary has maintained that the Constitution did not allow any region to secede, a position also taken by the government of Prime Minister Mariano Rajoy.

After the sentencing of Mr. Mas on Monday, Catalan separatist politicians immediately presented the ruling as the latest evidence of a Spanish judiciary working to stop Catalans from exercising their democratic right to vote.

Carles Puigdemont, who succeeded Mr. Mas as Catalan leader, also drew an unflattering comparison with the situation in Scotland, whose own government leader, Nicola Sturgeon, said on Monday that Scotland planned to hold a second independence referendum between the fall of 2018 and the spring of the following year.

“What a mistake!” Mr. Puigdemont wrote on Twitter. “What a difference with consolidated and healthy democracies” like that of Britain.

Catalan separatists face an uphill struggle to hold an independence referendum in 2017. But they have been encouraged by the example of Scotland, where Ms. Sturgeon on Monday said she would seek a referendum on independence.

Scots voted against separating from the rest of Britain in 2014, in a referendum held with the consent of the government in London. Ms. Sturgeon is arguing that another referendum is required because Scotland’s prospects have been changed by Britain’s planned exit from the European Union, after last June’s British referendum. While British voters overall decided to exit the European Union, 62 percent of voters in Scotland voted instead to remain.

Mr. Mas announced on Monday that he would appeal his sentence to the Spanish Supreme Court — but he also indicated that he was ready to take the case as far as European courts, given that he did not anticipate any appeal in Spain to be successful. Besides Mr. Mas, two other Catalan officials were also found guilty of disobedience on Monday for their part in staging the 2014 vote.

“The law is not equal for everybody,” Mr. Mas told reporters at a news conference in Barcelona. “People are being persecuted for their ideas.”

In Madrid, however, government officials presented the ruling as proof that no citizen is above Spanish law. Pablo Casado, a government spokesman, promised that “the government will ensure compliance with the law in Catalonia.”

In the 2014 nonbinding ballot, almost 81 percent voted for independence, but only one-third of eligible voters took part.

Ms. Mas was replaced as government leader in early 2016, as part of a deal between the separatist parties that hold a majority of seats in the Catalan parliament. Since then, his party has also become entangled in major corruption cases over the payment of kickbacks for public works in Catalonia.