I moved to Madrid to study and lost a lot of time working out which paperwork applies to whom. Here's the short version I wish I'd had. Corrections welcome, rules change.
NIE vs TIE
NIE is a number. It identifies you as a foreigner in Spain.
TIE is a card, for non-EU students staying more than six months. Your NIE is printed on it.
EU students don't get a TIE. Their NIE is on the EU registration certificate.
EU / EEA / Swiss students: the EU registration certificate
Staying more than three months? Apply in person within three months of entering Spain. Arrived in September → that's December.
Bring: form EX-18, paid Modelo 790 code 012, passport or ID, proof of enrolment, proof of health cover (an EHIC valid for your whole stay can work), and a signed statement that you have enough money.
It's issued on the spot at the appointment. Bring originals and a photocopy of everything.
Non-EU students: the TIE
Request it in person within one month of entering Spain, with form EX-17 and the paid Modelo 790 code 012.
Fingerprint appointments in Madrid can take three months or more, so start looking as soon as you know your arrival date. The booking site is sometimes down; try again later.
Booking is free on the official site. Don't pay anyone for an appointment: the police have arrested resellers.
Came without a visa (US, Colombia, Mexico, etc.)?
For higher education you can apply for your student stay from inside Spain, but at least two months before your 90 days end and two months before classes start. In practice that's often about a month after arriving.
Padrón (registering your address)
Registration form, original ID, rental contract (signed by everyone, six months or longer), the flat's cadastral reference, and if you signed online, proof of your latest rent payment.
No contract in your name? The person registered at the address can authorise you on the form.
Working while you study (non-EU)
With a long-term stay for higher education you can work up to 30 hours a week without a separate work permit, as long as it fits around your studies.
Full disclosure: a friend and I turned this into a free site, studentgo.eu. You pick your passport, answer a few questions and get your steps, documents and deadlines in order, each linked to the official source. No account needed. But everything above works without it.
This isn't legal advice. For a tricky case, ask your university's international office or a lawyer.