Quim Torra, a hardline separatist leader, was voted in by 66 votes in favour to 65 against.

Catalonia’s parliament has voted in a hardline separatist leader, bringing an end to seven months of direct rule from Madrid.

It came after four failed attempts since the separatists won a regional election in December.

Torra has vowed to end Spanish direct rule in Catalonia and to work towards achieving an independent Catalan Republic.

The unprecedented Spanish takeover is set to end when Torra is sworn in along with a new Catalan Cabinet.

However, Spanish authorities have warned the national government could reassert its authority if the new regional government breaks the law again. 

Spain’s prime minister, Mariano Rajoy, said he didn’t like what he had heard during the debate in the Catalan assembly. He said his judgment on Torra’s appointment will depend on the new leader's actions.