  Given a quasi-lattice ordered group $(G,P)$ and a compactly aligned product
system $X$ of essential C$^*$-correspondences over the monoid $P$, we show that
there is a bijection between the gauge-invariant KMS$_\beta$-states on the
Nica-Toeplitz algebra $\mathcal{NT}(X)$ of $X$ with respect to a gauge-type
dynamics, on one side, and the tracial states on the coefficient algebra $A$
satisfying a system (in general infinite) of inequalities, on the other. This
strengthens and generalizes a number of results in the literature in several
directions: we do not make any extra assumptions on $P$ and $X$, and our result
can, in principle, be used to study KMS-states at any finite inverse
temperature $\beta$. Under fairly general additional assumptions we show that
there is a critical inverse temperature $\beta_c$ such that for $\beta>\beta_c$
all KMS$_\beta$-states are of Gibbs type, hence gauge-invariant, in which case
we have a complete classification of KMS$_\beta$-states in terms of tracial
states on $A$, while at $\beta=\beta_c$ we have a phase transition manifesting
itself in the appearance of KMS$_\beta$-states that are not of Gibbs type. In
the case of right-angled Artin monoids we show also that our system of
inequalities for traces on $A$ can be reduced to a much smaller system, a
finite one when the monoid is finitely generated. Most of our results
generalize to arbitrary quasi-free dynamics on $\mathcal{NT}(X)$.
