Violent clashes erupted for a second night in Barcelona between police and protesters angry about the conviction of a dozen Catalan separatist leaders, as Spain launched an investigation Tuesday into an activist group organizing the demonstrations.

Thousands of people held vigils near the Spanish government offices in Catalonia's four provinces. But the gatherings turned into melees, with protesters hurling firecrackers and other objects at anti-riot officers and kicking temporary fences around the official buildings.

In Barcelona, protesters sang the Catalan anthem and shouted, "The streets will always be ours" and "Independence," while they called Spanish police "occupying forces" and urged them to leave Catalonia. Demonstrators erected improvised barricades with trash bins, fences and piles of cardboard that they set on fire.

The greatly outnumbered riot police went in with shields and batons, striking protesters in their path. They hit people on the legs mostly and fired foam-type anti-riot bullets that dispersed the crowds.

There were also clashes in Girona, Lleida and Tarragona, as well as smaller towns across Catalonia.

In a statement late Tuesday, the office of the Spanish prime minister said protesters were causing "damage" and "vandalism," and accused "groups who use street violence to break coexistence in Catalonia" of co-ordinating the rioting.

Most impromptu protests were responding to an online campaign by Tsunami Democratic, a loose, leaderless grassroots group that uses encrypted messaging apps to call for peaceful disobedience.

Fernando Grande-Marlaska, Spain's caretaker interior minister, said authorities were investigating the group.

Protesters shout during a demonstration in Barcelona on Tuesday, as Catalonia geared up for more upheaval a day after thousands of pro-independence activists stormed the city's airport. People there are expressing anger over Spain's jailing of several Catalan leaders following a failed secession bid. (Pau Barrena/AFP/Getty Images)

Vigils on Tuesday evening were initially called by the Catalan National Assembly, or ANC, and Omnium, two grassroots pro-secession groups whose leaders Jordi Sanchez and Jordi Cuixart were sentenced Monday to nine years in prison for sedition.

In written answers to questions sent to Sanchez in prison, the activist-turned-politician defended the non-violent nature of the Catalan independence movement.

"The risk of frustration is always there among certain people when there is a movement so big of millions," Sanchez wrote. "But I don't see any future for violence. We don't practise it, nor do we defend it."

Seven politicians were also given prison terms of around a decade in Monday's Supreme Court ruling and three more were fined for disobeying the laws as they pushed ahead with a banned referendum on Oct. 1, 2017, and briefly declaring independence based on its results before Spain crushed the defiance.

Flights cancelled, travellers stranded

On Tuesday, protesters also blocked highways, smaller roads and railway tracks for brief periods following an attempt to besiege Barcelona's international airport Monday night that left thousands of travellers stranded. Many, desperate to catch their flights, were forced to walk with their luggage on highways and across fields.

The airport authority said 110 flights were cancelled Monday and 45 Tuesday, when nearly 1,000 operated normally.

Officials said six people had been arrested — three on Monday and three on Tuesday. More than 170 people were reported injured, including about 40 police officers and a protester who lost an eye.

Passengers try to reach the Barcelona airport on Monday, after the road was blocked because of protests. (Jon Nazca/Reuters)

The court's ruling Monday also barred the 12 convicted Catalan separatists from holding public office. That has an immediate impact on the upcoming Nov. 10 Spanish election because six of of those convicted were planning to run as candidates in the national parliament.

The verdict is likely to be a central issue in the election campaign but "it is unlikely to substantially alter the electoral outlook unless the situation worsens significantly in the region," said Antonio Barroso, a political risk analyst with the London-based Teneo consulting firm.

He said Catalan separatist politicians wanted to use the backlash against the ruling to woo pro-independence voters to the polls.

Others have feared that swelling support for Catalan separatism because of the sentences could make the next political term even more key to either breaking the deadlock with separatists or making it a chronic problem.

Spain's caretaker prime minister and Spanish Socialist Workers' Party leader, Pedro Sanchez, who won the April election but failed to get support for a minority government, is hoping to remain in office.

'We will do it again'

Even from the early hours after the Supreme Court ruling was issued, very different views emerged from Madrid and Catalonia. While Sanchez called for beginning a "new phase" and urged Catalan separatists to abide by the law, the ruling invigorated the wealthy region's independence movement, with many of its leaders making new calls to work toward effective secession or repeating the slogan "we will do it again."

Cuixart told The Associated Press by email, via his lawyer, that he and the others sentenced by the Supreme Court will take their case to the European Court of Human Rights.

"We have the moral obligation to denounce [Spain's] authoritarian drift and appeal to European citizens to defend human rights," Cuixart wrote Tuesday.

Police and protesters clash during a demonstration against the jailing of Catalan separatists on Tuesday in Barcelona. The protests come after separatist leaders were jailed Monday for sedition. (Alex Caparros/Getty Images)

Catalan's regional president, Quim Torra, said secessionists won't give up their fight.

"A referendum is the most positive solution for solving this situation," he told foreign reporters in Barcelona on Tuesday.

Josep Borrell, the caretaker Spanish foreign minister who is soon due to become the European Union's top diplomat, said the court's ruling would not resolve the underlying political problems. Only dialogue "in the framework of the constitution" could do that, he said. Spain's constitution says the country is indivisible.

"Yesterday, today and tomorrow it is and remains a political problem that has to be solved," Borrell told foreign reporters, adding that Catalan separatists shouldn't ignore Catalans like him who are against independence.

Protests are likely to extend throughout the week. A three-day student strike begins Wednesday in the region, and a worker's union has called a separate strike for Friday.