A phase transition describes the sudden change of state in a physical system, such as the transition between a fluid and a solid. Quantum gases provide the opportunity to establish a direct link between experiment and generic models which capture the underlying physics. A fundamental concept to describe the collective matter-light interaction is the Dicke model which 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-ranged interactions between the condensed atoms. These are 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. The work opens the field of quantum gases with long-ranged interactions, and provides access to novel quantum phases.