The concept of rank of a commutative cancellative semigroup is extended to all commutative semigroups S by defining rank S as the supremum of cardinalities of finite independent subsets of S. Representing such a semigroup S as a semilattice Y of (archimedean) components Sα, we prove that rank S is the supremum of ranks of various Sα. Representing a commutative separative semigroup S as a semilattice of its (cancellative) archimedean components, the main result of the paper provides several characterizations of rank S; in particular if rank S is finite. Subdirect products of a semilattice and a commutative cancellative semigroup are treated briefly. We give a classification of all commutative separative semigroups which admit a generating set of one or two elements, and compute their ranks.