How long does a residential lease last in Spain?
Landlord and tenant agree the duration, but if it's under 5 years (7 if the landlord is a company), on expiry the lease is compulsorily extended by yearly periods until it reaches that minimum. This is the mandatory extension in article 9.1 of the Urban Leases Act (LAU).
The extension is only compulsory for the landlord: you can choose not to renew any year by giving 30 days' notice before expiry. If the contract states no duration, it's deemed signed for one year, with the same right to renewal (art. 9.2).
Deadlines count from the contract date or from when the home was handed over to you, if later. If that date is disputed, it's up to you to prove it.