We present a rigorous statistical-mechanics theory of nonlinear many mode laser systems. An important example is the passively mode-locked laser that promotes pulse operation when a saturable absorber is placed in the cavity. It was shown by Gordon and Fischer [Phys. Rev. Lett. 89, 103901 (2002)] that pulse formation is a first-order phase transition of spontaneous ordering of modes in an effective “thermodynamic” system, in which intracavity noise level is the effective temperature. In this paper we present a rigorous solution of a model of passive mode locking. We show that the thermodynamics depends on a single parameter, and calculate exactly the mode-locking point. We find the phase diagram and calculate statistical quantities, including the dependence of the intracavity power on the gain saturation function, and finite size corrections near the transition point. We show that the thermodynamics is independent of the gain saturation mechanism and that it is correctly reproduced by a mean field calculation. The outcome is a new solvable statistical mechanics system with an unstable self-interaction accompanied by a natural global power constraint, and an exact description of an important many mode laser system.