You need both. Here is how it goes:
1) Get a job offer in Spain. They will need to get you an 'Oferta de Trabajo' which is an official form.
2) Take this with the other stuff you need (it's on the embassy website) to the embassy and submit it.
3) In a while your visa should come and you will have to return to the embassy to have it put in your passport. Then you can go to Spain.
4) In Spain you have to apply for residency, which includes a 'work permit'. This takes some time also, and your company should be helping with this by hiring you a gestor.
Now - the visa takes eons. The card takes longer - it took me almost a year. So after you apply for the visa just go to spain and have the company pay you under the table until you get the visa - then you'll have to go home to get it.
Sound like a pain in the ass? It is. Let me know if you have more questions.
Ciao
-L