Spain's top court has officially ruled that Catalonia's disputed independence referendum was illegal because a regional law that backed it was against Spain's constitution.

The Catalan regional parliament passed the so-called "self-determination referendum law" in early September.

Regional leaders went on to stage the October 1 referendum on whether the region should separate from Spain.

Spain's Constitutional Court had earlier suspended the law temporarily while judges assessed the Spanish government's objection to it.

In its ruling on Tuesday, the court said the law was against national sovereignty and the "indissoluble unity of the Spanish nation".

The court said that the parliamentary session that approved the law was also illegal.

Catalan government spokesman Jordi Turull said he was not surprised, saying: "We are facing an executive power in the state that uses the judiciary branch to block the legislative."

In Barcelona protesters gathered for a fresh round of demonstrations in Barcelona to demand the release of two leaders of Catalonia's pro-independence movement who were jailed in a sedition probe.

A Madrid judge on Monday provisionally jailed Jordi Sanchez and Jordi Cuixart, the leaders of grassroots organisations Catalan National Assembly and Omnium Cultural.

The judge ruled they were orchestrators of massive demonstrations on September 20 to 21 in Barcelona that hindered a police operation against preparations for the October 1 independence referendum.