In this paper we show that if I is an ideal of a commutative semigroup C such that the separator SepI of I is not empty then the factor semigroup $$S=C/P_I$$ ( $$P_I$$ is the main congruence of C defined by I) satisfies Condition $$(*)$$ : S is a commutative monoid with a zero; The annihilator A(s) of every non identity element s of S contains a non zero element of S; $$A(s)=A(t)$$ implies $$s=t$$ for every $$s, t\in S$$ . Conversely, if $$\alpha $$ is a congruence on a commutative semigroup C such that the factor semigroup $$S=C/\alpha $$ satisfies Condition $$(*)$$ then there is an ideal I of C such that $$\alpha =P_I$$ . Using this result for the multiplicative semigroup $$D_{mult}$$ of a unique factorization domain D, we show that $$P_{J(m)}=\tau _m$$ for every nonzero element $$m\in D$$ , where J(m) denotes the ideal of D generated by m, and $$\tau _m$$ is the relation on D defined by $$(a, b)\in \tau _m$$ if and only if $$gcd(a, m)\sim gcd(b, m)$$ ( $$\sim $$ is the associate congruence on $$D_{mult}$$ ). We also show that if a is a nonzero element of a unique factorization domain D then $$d(a)=|D'/P_{J([a])}|$$ , where d(a) denotes the number of all non associated divisors of a, $$D'=D/\sim $$ , and [a] denotes the $$\sim $$ -class of $$D_{mult}$$ containing a. As an other application, we show that if d is one of the integers $$-1$$ , $$-2$$ , $$-3$$ , $$-7$$ , $$-11$$ , $$-19$$ , $$-43$$ , $$-67$$ , $$-163$$ then, for every nonzero ideal I of the ring R of all algebraic integers of an imaginary quadratic number field $${\mathbb Q}[\sqrt{d}]$$ , there is a nonzero element m of R such that $$P_I=\tau _m$$ .