Emergencies is "urgencias" in Spanish and 112 is the general emergency telephone number to dial in Spain. Most chemists ('farmacia's') will have information about where you can go for emergency treatment, such as which clinics and what medical treatment can be obtained. If you suffer with a particular medical condition or allergic reaction to penicillin or other medicine, make sure you know what the Spanish translation for this is, in case of an emergency.
If you need to call out a doctor in an emergency, make it clear that you have a
European Health Insurance Card (EHIC) and that you want to be treated under the EU arrangements, or that you have International health insurance. If you are treated in a state medical centre (centro de salud) or out-patient clinic (ambulatorio) you will probably be referred to a state hospital for treatment, so carry details of your private medical insurance around with you.