Apple has a great short list of international web sites and phone numbers to get support. It might be worth a call to make sure you understand how to get service in Spain and if they are OK with a purchase of the Mac or AppleCare from outside the country or if it's better to buy one or both from within Spain.
The Warranty is established at the time and country of sale. I think it's possible to buy AppleCare in a country different than the purchase of the mac - but you might want to talk directly to Apple before buying either at 1-800-MY-APPLE.
You might save time and hassle by getting an OK in writing or an email to buy here and get service there.
No matter where in the world you are - you technically have to go through the support organization that is in place for the country where the mac was first purchased and/or the country where AppleCare was purchased.
I have never had issues when I buy directly from Apple and get service from Apple worldwide. The US applecare arranged service for me in Spain well before they opened Retail Stores in Spain.
You can call them directly in the country of purchase, country of convenience or pretty much any Apple owned employee. For countries where Apple has no direct sales presence, you may be limited to that country and have to deal with that country's official support vendor and not with Apple directly.
When you are in a country with an Apple Retail presence, you almost always can get great service from them or an independent but Authorized AppleCare vendor. Countries without that presence may be just as good or more limited and depend more heavily on the vendor that handles support and not Apple itself.
The Apple warranty and repair policies although full of legal terms, the section that describes what is covered and how to get service written in plain english and is short in length. This page shows the specific AppleCare plans around the world and this chart shows some of the coverage differences for other non-CPU AppleCare service plans.