The social security system in spain is similar to the UK. 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 made in the past.
When you contract to any position 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 (check your wage slip to make sure that this has been done!). You will need to obtain your NIE number first. But beware! Many small businesses pay some or all their staff cash in hand so they will not be eligible for social security benefits, including health care. Other employers may register you, but claim you are working less hours than you actually 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 much lower than you should actually be entitled to.
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 (autonomo) then this information is provided under our 'Registering a Small Business' section - Alternatively if you are already regsitered in the UK system you can work in spain for up to 2 years, and you will still be entitled to spanish healthcare. See the UK's Department for Work and Pensions website for details.
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.