Joaquin Garcia's absence was only noticed when he became eligible to collect a long-service award.
The 69-year-old, whose job was to supervise the building of a waste water treatment plant, has since retired.
He denied the allegations and said he was a victim of bullying. A court found in the authority's favour and ordered him to pay the fine.
Mr Garcia was paid €37,000 a year before tax by a water company run by local authorities in the south-western city of Cadiz. His fine was equivalent to one year's salary after tax and was the most that the company could legally reclaim.
The court heard that the boss of the water company had not seen him for years despite occupying an office opposite his.
The water company thought he was supervised by the local authorities and vice versa.
The deputy mayor noticed his absence when Mr Garcia became due to receive a plaque for 20 years' service.
Mr Garcia says he was bullied due to his family's politics, and was sent to the water company to be out of the way.
People close to him told Spanish newspaper El Mundo that he was reluctant to report it as he had a family to provide for, and worried that at his age he would not get another job.
They said he did go to the office, although not for full business hours every day, and that he dedicated himself to reading philosophy.