Citizens from the European Union do not need a visa for Spain. With a valid Identification Card or passport, they can stay as long as they want. However, citizens from all other countries will require a visa stamped in their passport if they wish to remain in Spain longer than 90 days.
Regarding Visas, the Spanish Consulate in New York has posted this information in their Web site:
A student visa is mandatory for any foreigner wishing to study in Spain for 3 months or longer. Citizens of other countries can travel to Spain without a visa for tourist or business purposes for up to 90 days, after which time a visa is required. The visa is processed in your country of residence prior to your departure. You cannot get the visa in Spain, and you cannot have it sent to you. The visa is affixed in your passport before you depart your country, and must be presented at the border Officials upon your entry into Spain.
All student visas are valid for a period of 90 days from your entry day into Spain, during which time you must contact the local authorities to acquire a student residency card. This "Spanish Student Residency Card" is then valid for as long as you are enrolled in the program in Spain.
Due to the overwhelming demand for student visas, it is important that you allow enough time for the Consulate to process your visa. On specially busy days at the Consulate, it is occasionally impossible to attend to all the applicants, so it is best to arrive early. Personal appearance is required in order to submit the documentation. We understand that this is difficult for some students. You must present the following documents:
You must also submit one of the following items to guarantee living expenses while in Spain:
Plan your trip ahead of time! Be advised that answer to your application might take several weeks depending on each case.
For more information see the Spanish Consulate in New York's Web site at http://www.spainconsul-ny.org/!consula.doi/!visastu.htm
Find the Consulates of Spain in your country.