The case started with confusion over where a civil servant in southern Spain worked. Now a court has ruled he must pay back nearly 27,000 euros, or $30,500 USD, in wages because for years he actually didn't work at all.

The employee of a water utility owned by the Spanish city of Cadiz didn't appear at its office for up to six years and "did absolutely no work" for three years prior to his retirement in 2011, said the ruling issued last month and provided to The Associated Press Friday.

It didn't explain why the worker, who cannot be named under Spanish law, went undetected until his case was discovered in 2010, shortly before he was due to receive a plaque recognizing him for 20 years of service.

Former Cadiz Deputy Mayor Jose Blas Fernandez said in a telephone interview he initiated the investigation after reviewing personnel records and realizing no one had seen the worker for a long time after his transfer to the utility from a city hall job.

The Aguas de Cadiz utility told Blas Fernandez it thought the worker had transferred back to city hall, but that wasn't the case, Blas Fernandez said.

He got the worker on the phone, ordered him to report to city hall and said he was evasive when asked what sort of tasks he had been doing in recent years.

Cadiz city officials sought the penalty representing one year of the worker's net pay, the maximum allowed. But the worker appealed, starting a legal battle that lasted years until the court ruled against him.

The case has made headlines across Spain this week, and current Cadiz Deputy Mayor Martin Vila told reporters Friday he was amazed that "a person could be hired for years and collecting (pay) without doing anything whatsoever."

It has also taken on political undertones, with Vila citing allegations the worker had been a victim of workplace "bullying" by members of the conservative Popular Party. It ruled Cadiz from 1995 until its ouster last year by a far left coalition led by the Podemos party.

Vila didn't provide more details but said the allegations "would be despicable if confirmed."

Blas Fernandez said the worker never mentioned any bullying allegations earlier.

The worker sent city hall a letter denying he abandoned his job and asking officials not to force him to pay back the money.

Vila didn't say whether officials have responded but pledged that the city administration would immediately focus on "the optimization of human resources" to reduce the risk of similar cases.

The worker's lawyer, Fernando Lepiani, didn't respond to messages seeking comment.