Nationalists have regained control of Catalonia's regional government as a new cabinet was sworn into office.

The move automatically ends just over seven months of direct rule by Spain's central government.

The cabinet is led by Quim Torra, a close aide to former Catalonia leader Carles Puigdemont.

Mr Torra said he is willing to talk to Spain's new Prime Minister Pedro Sánchez.

He said: "Let's talk, let's address this issue, let's take risks, you and us." 

It comes on the day that Socialist Pedro Sánchez, who has said he wants talks on Catalonia but opposes any independence referendum, was officially sworn in as new Spanish prime minister.

Mr Sánchez' predecessor, the conservative Mariano Rajoy, imposed direct rule over Catalonia at the end of October after nationalists led by Mr Puigdemont held an independence referendum deemed illegal by Spanish courts.

According to the Spanish constitution, direct rule from Madrid was due to end the moment a new regional government was put in place in Barcelona.

It took several tense months, after snap regional elections were held in December, for Catalan nationalists to get a new cabinet approved by the regional parliament and to get past Madrid's moves to block any candidate who was in self-imposed exile, like Mr Puigdemont, or in jail.

In Madrid, Mr Sánchez was sworn in before King Felipe, his right hand on the constitution - the first time that was not done with the Bible or a crucifix.

He became prime minister with only 84 seats for his Socialist Party in the 350-member assembly thanks to support from the hard-left Podemos and smaller nationalist parties.

He said he intends to steer the country through to mid-2020 when the parliamentary term ends.

But his majority - the smallest for a Spanish government since the return to democracy following Francisco Franco's death in 1975, makes it unclear how long his administration can last.