A large-deviations principle (LDP) is derived for the state at fixed time, of the multiplicative coalescent in the large particle number limit. The rate function is explicit and describes each of the three parts of the state: microscopic, mesoscopic and macroscopic. In particular, it clearly captures the well known gelation phase transition given by the formation of a particle containing a positive fraction of the system mass. Via a standard map of the multiplicative coalescent onto a time-dependent version of the Erdős-Rényi random graph, our results can also be rephrased as an LDP for the component sizes in that graph. The proofs rely on estimates and asymptotics for the probability that smaller Erdős-Rényi graphs are connected