Court declares election illegal