Non Lucrative Residence Permit:
This type of permit allows someone to reside in Spain but do not entitle to engage in a professional activity or employment. Proof of means of support and a private health insurance are required.
Student visas and permits:
A student visa is mandatory for any third country national wishing to study in Spain for more than 90 days. Original official certificate of admission verifying enrolment as a full-time student in an official university or school in Spain is required.
Most immigration permits can be renewed. The renewal application must be submitted 60 days before your resident permit expires and 90 days after it has expired, although that might incur a fine. If you present the documentation during the 60 days before the expiry of your permit, the permit will be extended until a decision is taken on your application.
Residence permit under exceptional circumstances:
Continued irregular residency in Spain for a period of 3 years provides the right to apply for a residence permit, and therefore remain in the country.
Usually for this type of permit you will need a work contract or set up an economic activity of your own.
Residence permit for humanitarian reasons:
Third country nationals that have a serious illness that require specialised healthcare that is unavailable in their country of origin may obtain a permit under humanitarian reasons.
The same for victims of crimes involving domestic violence or for those who show proof that transferring them to their country of origin, or applying for the corresponding visa, implies a serious risk to their safety.