Guide on Social Security Number in Madrid
In Spain your Social Security number is in no way related to your tax payment. For any tax related issues, you will need a NIE (foreigners), NIF (Spaniards) and CIF (Companies). Your social security number is a completely different number and is issued by the Social Security offices. Social security is paid separately from income tax, and your social security number is only needed when dealing with medical or pension issues or other matters regarding government financial assistance.
EU and non-EU citizens need an NIE in order to file taxes, start a business, open a bank account (not necessary for foreign accounts) and for almost all other forms of bureaucracy that you will encounter. The immigration service will issue you this number once you obtain resident status. (See the section “NIE and Residency”.
NIF (Número de Identificación Fiscal)
This is the tax ID number for all individuals that it is the same number as your NIE. Once you have an NIE, you do not need to re-apply for an NIF. If and when you have to pay taxes, use your NIE number to identify yourself. If you are a non-resident who has to pay taxes in Spain, you may have an NIF issued without having an NIE. This, of course, does not mean you get automatic residency in Spain, nor will it make it any easier to get residency.
CIF (Certificado de Identificación Fiscal)
This is the same as the NIF, but specific to companies.