Surface-attached bacterial biofilms cause disease and industrial biofouling, as well as being widespread in the natural environment. Density-dependent quorum sensing is one of the mechanisms implicated in biofilm initiation. Here we present and analyse a model for quorum-sensing triggered biofilm initiation. In our model, individual, planktonic bacteria adhere to a surface, proliferate and undergo a collective transition to a biofilm phenotype. This model predicts a stochastic transition between a loosely attached, finite, layer of bacteria near the surface, and a growing biofilm. The transition is governed by two key parameters: the collective transition density relative to the carrying capacity, and the immigration rate relative to the detachment rate. Biofilm initiation is complex, but our model suggests that stochastic nucleation phenomena may be relevant.