A court in Spain on Tuesday convicted 19 former top officials from the ruling Socialists in Andalusia of graft for their role in one of the biggest corruption cases in the country's modern history.

The ruling comes as acting Prime Minister Pedro Sanchez struggles to secure enough support from other parties to be sworn in for another term.

His Socialist Party won a repeat general election on November 10, but once again fell short of an absolute majority in parliament and the judgement could complicate his talks with other parties.

The 19 were convicted by a Seville court of distributing without any control hundreds of millions of euros meant to help the unemployed and companies in difficulty in the southwestern region, in what became known as the ERE case -- the Spanish acronym for a mass-layoff plan.

In a trial that got under way in December 2017 and lasted a year, prosecutors estimated that between 2000 and 2010 members of the Andalusian administration diverted 680 million euros ($752 million) in public funds.

They say it was discreetly passed on to people and businesses, often with close ties to the Socialist Party, some of whom were not affected by layoffs -- which the funds were intended to compensate.

In its 1,821-page ruling the court found there was an "absolute lack of control" in the management of the funds.

Among those convicted were two former regional presidents of Andalusia, Manuel Chaves and Jose Antonio Grinan -- both former ministers who had served under Socialist premier Felipe Gonzalez.

Public Works Minister Jose Luis Abalos was quick to distance the outgoing Socialist government from the case, saying it "does not affect the current government nor the current leadership of the Socialist party".

But the verdict drew swift condemnation from the rightwing opposition Popular Party (PP) which said it showed the Socialists resorted to cronyism -- using taxpayers' money to reward supporters with jobs and benefits -- to maintain their decades-long grip on the region.

Manuel Chaves (R) and Jose Antonio Grinan are among 21 former senior Socialists in the Andalusian regional government accused in the trial, which lasted a year
Manuel Chaves (R) and Jose Antonio Grinan are among 21 former senior Socialists in the Andalusian regional government accused in the trial, which lasted a year POOL / Julio Muñoz

"Sanchez came to power unfairly condemning an honest government. Now he must be consistent and take responsibility for the worst case of corruption in Spain's history," tweeted PP head Pablo Casado.

Sanchez came to power nearly 18 months ago after ousting former PP premier Mariano Rajoy in a no-confidence vote over a corruption scandal which found the conservative party had profited from a kickbacks-for-contracts scheme.

The court on Tuesday found Grinan guilty of embezzlement and misappropriation of public funds and sentenced him to six years behind bars. It also banned him from public office for 15 years.

Chaves was convicted of maladministration and also banned from public office for nine years.

The scandal broke in 2010, at the height of Spain's financial crisis, as Socialist premier Jose Luis Zapatero was introducing a slew of austerity measures that included cutting civil servants' wages.

The affair forced Grinan to resign as head of the regional government of Andalusia, but during the trial, both he and Chaves denied fraud.

The case also drew criticism from the left.

"The sentence confirms that for years, Socialist leaders in Andalusia used public money to support a mafia network that bought social peace and fed corruption," said Alberto Garzon, the leader of Izquierda Unida, or United Left, which is allied with the radical leftwing Podemos.

Last week, Sanchez agreed in principle to form a coalition government with Podemos.

In January, after 36 years of holding power in Spain's most populous region, the Socialists lost control of Andalusia's government to a coalition comprising PP and the centre-right Ciudadanos.

That same election saw the electoral breakthrough of the far-right party Vox, which won its first seats.