Middle French
It originates in the 16th century, as a shortening of "captain general", which rank was taken from Middle French "capitaine général".