The origin of dust in galaxies is still a mystery. The majority of the refractory elements are produced in supernova explosions, but it is unclear how and where dust grains condense and grow, and how they avoid destruction in the harsh environments of star-forming galaxies. The recent detection of 0.1 to 0.5 solar masses of dust in nearby supernova remnants suggests in situ dust formation, while other observations reveal very little dust in supernovae in the first few years after explosion. Observations of the spectral evolution of the bright SN 2010jl have been interpreted as pre-existing dust, dust formation or no dust at all. Here we report the rapid (40 to 240 days) formation of dust in its dense circumstellar medium. The wavelength-dependent extinction of this dust reveals the presence of very large (exceeding one micrometre) grains, which resist destruction. At later times (500 to 900 days), the near-infrared thermal emission shows an accelerated growth in dust mass, marking the transition of the dust source from the circumstellar medium to the ejecta. This provides the link between the early and late dust mass evolution in supernovae with dense circumstellar media.