If you are already in Spain, are a non-EU citizen, and have a family member or partner from an EU country, you can apply for the EU family residence permit.
If you are a non-EU citizen (i.e., from a country in the EU or the Schengen Area) and want to live and work legally in Spain without time limits, all you have to do is:
- Obtain the NIE: (Foreigner Identification Number).
- Obtain the CUE: (Certificate of Citizen of the European Union).
If you want to know how to obtain Spanish Nationality, read this article.