I just found this.
The Social Security System in Spain
The Spanish social security system is much like the British one, in that you pay your contributions every month, and that entitles you to a pension, unemployment benefit, sick pay, maternity pay and the right to receive free healthcare. The amount of pension or benefit you receive depends on the level of contributions you have been paying.
Once you take any job in Spain your employer is required to register you in the social security system and to deduct any contributions payable by you from your wages. You will need to register for your NIE number first. You should be a little careful too: some small businesses pay all their staff cash in hand and those staff will not be eligible for Social Security benefits, including health care. Other employers may register you, but claim you are working less than you are, thus saving themselves some money in contributions. In this situation you will still be eligible for health care, but if you become unemployed or have to take sick leave, your benefits will be lower. Obviously you may not have much of a choice as to who you work for, but we would strongly recommend that you do not work cash-in-hand.
If you are self-employed you will have to go to the local Social Security office and fill in all the paper-work yourself. Unless your Spanish is very good, then it is probably advisable to get a gestor (official agent - a bit like a lawyer for menial bureaucracy) to do this for you. The minimum monthly contribution for the self employed in Spain is currently 225EUR per month.
Claiming Social Security Benefits in Spain
If you are claiming jobseeker’s allowance, a pension or certain other benefits when you leave the UK, you may be able to get your claim transferred to Spain. See The Department for Work and Pensions website for details. If you leave a job in order to move to Spain, you will not be able to claim any benefits.
If you have been employed in Spain for 6 months and you lose your job, you will generally be entitled to Spanish unemployment benefit. If you are employed or self-employed, you will also be entitled to sick pay, maternity pay and, when you retire, a pension. All benefits are paid at variable rates depending on the level of your contributions. If you have been paying minimum social security contributions the amount you will receive in benefits is currently around 750 EUR per month. If you are planning to live in Spain long term you should contact the DSS overseas department (above) in order to get your UK NI contributions transferred to the Spanish system.