Spain has claimed victory in an argument with Britain over the status of Gibraltar, after the European Parliament passed a law that referred to the peninsula as a “colony of the British Crown”.