Article 597 [source]

Spanish Criminal Code
English translation

Any Spaniard or foreigner who, while in the national territory, crosses or attempts to cross into an enemy country when prohibited by the Government, will be punished with a fine of six to twelve months.