We present an experimental and theoretical study on the gain mechanism in a photonic-crystal-cavity nanolaser with embedded quantum dots. From time-resolved measurements at low excitation power we find that four excitons are coupled to the cavity. At high excitation power we observe a smooth low-threshold transition from spontaneous emission to lasing. Before lasing emission sets in, however, the excitons are observed to saturate, and the gain required for lasing originates rather from multi-excitonic transitions, which give rise to a broad emission background. We compare the experiment to a model of quantum-dot microcavity lasers and find that the number of excitons that must be included to fit the data largely exceeds the measured number, which shows that transitions involving the wetting layer can provide a surprisingly large contribution to the gain.