BARCELONA, SPAIN -- Jailed Catalan leader Oriol Junqueras, who is serving 13 years for a failed 2017 independence bid, left prison Tuesday to teach in university as part of a day-release programme.

Under the terms of a deal approved by the separatist-dominated Catalan regional government, Junqueras is allowed to leave Lledoners prison north of Barcelona three days a week to teach a course on the history of western thought.

"Teach and learn. Always. Thank you everyone for your support," he tweeted over a picture of him leaving prison late on Tuesday morning for his first day on the job.

A historian by training, Junqueras' new role will allow him to leave prison for six hours at a time to take up a voluntary teaching post at the University of Vic, the Central University of Catalonia.

The decision was taken last week by the regional government, which enjoys broad powers over prison administration and has already approved a similar day-release programme for most of nine separatists jailed in October over the 2017 independence bid.

But Spanish prosecutors have said they would appeal the move, reproaching the Catalan government for giving the prisoners too much freedom.

Junqueras served as deputy head of the Catalan administration at the time of the independence bid and still heads the ERC, one of the two separatist parties in Catalonia's ruling coalition which recently opened talks with the government of Prime Minister Pedro Sanchez to try and resolve the political conflict.