Landlord and tenants rights in Spain are regulated by The "Ley de Arrendamiento Urbano (LAU 29/1994)", learn what rights have both in Spain.
Upon signing the contract there is a legal obligation on the tenant to provide a deposit of one month’s rent. The deposit will stay in the possession of the landlord until the lease period has ended.
At the end of the lease, the landlord has one month to return the deposit. If it is necessary to use part of the deposit to return the property to its condition prior to the leasing, the balance should be repaid within one month following the termination of the lease.
The deposit may not be used instead of the final month’s rent. It should be noted that the tenant in Spain is liable for any wear and tear through normal usage of the property, unless otherwise agreed.
So, any repairs that need to be carried out are paid for with the deposit, and any left over is returned to the tenant.
The only legally recognized deposit is to the value of one-months rent.