The leader of the union representing firefighters has failed to be re-elected after losing to his rival in a ballot of members.