Unlike in some countries, there are three distinct branches of police force in Spain.
1. Policia Local (Local Police)
2. Policia Nacional (National Police)
3. Guardia Civil (Civil Guard)
Each have very distinct roles, but often work the same locations, which can be confusing to outsiders.
Perhaps their most common feature is that all of them carry a handgun. Another feature of nearly all police in Spain is their zero tolerance for disrespect. Whereas the police in countries such as the UK and Ireland often take a softer, more diplomatic approach, many a drunk foreigner has ended up in the back of a Spanish police van (or ambulance!) for having disrespected or insulted the police during the course of their duties.
1. Policia Local
These are organised and funded by each local Town Hall (Ayuntamiento). They wear blue/light blue uniforms and drive vehicles marked with white and light blue.
Their typical duties include directing traffic and enforcing parking, traffic violations and vehicle checks, enforcing business and licencing rules (e.g. bar closing times, loud music restrictions, or tables encroaching onto a pavement etc). They also deliver official notices such as court summonses and public complaints (denuncias).
2. Policia Nacional
These are highly trained and are charged with dealing with more serious crimes (e.g. robbery, assault, rape, murder, fraud etc). They also have specialised groups focusing on organised crime, drug smuggling and money laundering. They also organise the registration of all foreigners in Spain and are responsible for issuing NIE and Residencia Certificates.
Policia Nacional officers wear dark navy blue/black uniforms. Their vehicles are typically navy blue and white.
3. Guardia Civil
These are technically military officers as opposed to police. They are organised by the Ministry of the Interior and are responsible for issues of national security, such as drug-smuggling, illegal immigrants, anti-terrorism, high-tech computer crime and associated money laundering. The Guardia Civil are also responsible for policing the highways. Most visitors will only ever encounter the Guardia Civil on a motorway or main road, perhaps conducting a vehicle checkpoint or carrying out random breath tests. They all wear a distinctive Green uniform.
Whilst any particular division of police officer can detain an offender suspected of committing an offence outside of their remit and hand them over to the correct division, the reality is that a particular division or officer may be focused on a particular task and will sometimes turn a blind eye to infractions outside of their own jurisdiction. For instance, the Policia Nacional may ignore even blatant parking violations around town, whilst the Policia Local might ignore somebody speeding on the autopista. Other times, they might choose to deliver a stern lecture but not actually report the matter for prosecution.
However, residents and visitors to Spain are strongly advised not to commit any infractions, regardless of who might be watching !!