NIE (Número de Identidad de Extranjero): This is your I.D. number in Spain and is issued once you obtain your residency (you will find the number on your Residency Card). This number is vital for just about any form you need to complete and for basic things like filing taxes, opening a bank account or starting a business. All foreigners (EU and non-EU) get issued an NIE.
DNI (Documento Nacional de Identidad): This is the I.D. number for Spanish citizens and is the same on their driver’s license. You will be asked for this a lot, in which case you should supply your NIE.
NIF (Número de Identificación Fiscal): This is a personal tax I.D. number. For Spaniards, it's the DNI plus one letter. For foreigners, it's the same number as your NIE. However, your NIF does not automatically become valid once you have your NIE, you need to apply for it. EU citizens can have a NIF issued first, but then are required to apply for the NIE.
CIF (Certificado de Identificación Fiscal): a NIF equivalent for companies.
Social Security Number (Número de Seguridad Social): Your first employer gets you this number when you start your first job in Spain and you then keep the same number for subsequent employment. Self-employed persons need to apply for this number.
TIE (Tarjeta de Extranjero): Often confused with the NIE, the TIE is the card which is issued to foreigners who have entered Spain via a visa or residence permit after 6 months. The TIE will have your NIE number printed on it, and you can use it as I.D. However, if you’re in Spain for a period of time, for a short study period or for seasonal work, you don’t need to apply for a TIE as you usually aren’t permitted to stay in Spain for longer than the time required to obtain the TIE.