A phase transition describes the sudden change of state of a physical system, such as melting or freezing. Quantum gases provide the opportunity to establish a direct link between experiments and generic models that capture the underlying physics. The Dicke model describes a collective matter-light interaction and has been predicted to show an intriguing quantum phase transition. Here we realize the Dicke quantum phase transition in an open system formed by a Bose-Einstein condensate coupled to an optical cavity, and observe the emergence of a self-organized supersolid phase. The phase transition is driven by infinitely long-range interactions between the condensed atoms, induced by two-photon processes involving the cavity mode and a pump field. We show that the phase transition is described by the Dicke Hamiltonian, including counter-rotating coupling terms, and that the supersolid phase is associated with a spontaneously broken spatial symmetry. The boundary of the phase transition is mapped out in quantitative agreement with the Dicke model. Our results should facilitate studies of quantum gases with long-range interactions and provide access to novel quantum phases.