For flights within Spain, if you are a national of any country in the European Union you can travel with a national ID card or passport, even if they have expired. If you are a national from a country outside the EU and you don't have a valid document, you can show your driving licence provided it was issued in Spain.
For flights within the European Union , EU legislation requires all passengers (including children) to present a valid ID document or passport to be able to travel. In case of the theft, loss or expiry of your documents, check the EU regulations for each country to find out how to proceed.
For flights to destinations outside the European Union, you will always need to present a valid passport and any other documents required by the destination country. If you are a Spanish national and your passport has been lost or stolen, or you notice before you leave Spain that it is about to expire, check the government website administración.gob.es (only available in Spain) to find out what to do.
Remember, some countries require your passport to be valid for at least six months from the start of your trip. Check the expiry date well in advance of your trip.
If you have a different nationality, check with the authorities in your country or with your embassy or consulate, depending on where you are.