Image copyright Getty Images Image caption Huge crowds of pro-independence supporters have gathered in Barcelona

The Scottish government has said it "respects and understands" the position of the Catalan government, which has declared independence from Spain.

In a statement, External Affairs Secretary Fiona Hyslop did not explicitly recognise Catalonia as an independent state.

But she said the people of Catalonia "must have the ability to determine their own future".

And she called for a "process of dialogue" to resolve the crisis.

It came after Catalan MPs voted to declare independence from Spain by 70 to 10 in a ballot boycotted by the opposition.

In response, the Spanish parliament approved direct rule over the region.

Spanish Prime Minister Mariano Rajoy had told senators direct rule was needed to return "law, democracy and stability" to Catalonia.

He added: "Spain is a serious country, it is a great nation and we are not prepared in any way to allow some people to liquidate our constitution."

Downing Street has said the UK will not recognise the declaration of independence - a stance mirrored by major powers including France, Germany and the US, and by the EU itself.

European Commission chief Jean-Claude Juncker said the EU "doesn't need any more cracks, more splits".

Media playback is unsupported on your device Media caption The moment Catalan parliament declared independence

Crowds have been celebrating the declaration of independence and Spanish flags have been removed from some regional government buildings in Catalonia.

The crisis began earlier this month when Catalonia held a controversial referendum on independence, which had been ruled illegal by Spain's constitutional court.

In her statement, Ms Hyslop said: "We understand and respect the position of the Catalan government.

"While Spain has the right to oppose independence, the people of Catalonia must have the ability to determine their own future.

"Today's Declaration of Independence came about only after repeated calls for dialogue were refused."

Image copyright EPA Image caption Mariano Rajoy's government has imposed direct rule on Catalonia

Ms Hyslop called on those who "consider themselves friends and allies of Spain" to encourage talks between the two sides to find a way forward that "respects democracy and the rule of law".

She said the imposition of direct role "cannot be the solution and should be of concern to democrats everywhere."

And she said the EU had "political and moral responsibility" to help identify a way of resolving the situation peacefully and democratically.

Her statement was released as a spokesman for the UK prime minister said the country "does not and will not recognise the unilateral declaration of independence made by the Catalan regional parliament".

'Rule of law'

The spokesman added: "We continue to want to see the rule of law upheld, the Spanish constitution respected, and Spanish unity preserved."

The Catalan independence movement has had close links with its Scottish counterpart since the 2014 independence referendum in Scotland.

Several prominent SNP figures were in Barcelona for the Catalan referendum, which saw hundreds of people injured as Spanish police tried to prevent the vote taking place.

How did we get here?

The Catalan government said that of the 43% of potential voters who took part in the referendum on 1 October, 90% were in favour of independence.

After the referendum, Catalan President Carles Puigdemont signed a declaration of independence but delayed implementation to allow talks with the Spanish government.

A deadline set by Madrid for him to clarify his intentions came and went, prompting Mr Rajoy to announce plans to impose direct rule.

Catalonia is one of Spain's richest, most distinctive regions and enjoys a high degree of autonomy.

But many Catalans feel they pay more to Madrid than they get back, and there are historical grievances too, in particular Catalonia's treatment under the dictatorship of General Franco.

Catalans are divided on the question of independence - an opinion poll earlier this year said 41% were in favour and 49% were opposed to independence.