U.S. citizens visiting Spain who want to drive in Spain must obtain an international driving permit prior to their arrival. An international driving permit (IDP) translates your state-issued driver’s license into 10 languages so you can show it to officials in foreign countries to help them interpret your driver’s license. The IDP is not valid by itself and must be carried with your driver’s license. Click the following link for more information on driving overseas.
By law, you can use your foreign driver's license for the first 6 months if you are from outside the EU or for two years if you are from within the EU or EEA (European Economic Area).
U.S. citizens who are residents of Spain must obtain a valid Spanish driver’s license. At this time, there is no agreement between the United States and Spain for the validation of a U.S. driver’s license; therefore, holders of a U.S. license must attend a Spanish driving school and take the Spanish exam.
If you have a driver's license from another country, we recommend contacting their Embassy in Spain and asking what agreements they have. You might not need to sit the exam again or maybe just the driving. Better find out! It's not a cheap or easy process
You can find more information on the Spanish Traffic Authority website.
Information from the U.S. Embassy website.