Cavity quantum electrodynamics (cavity QED) describes the coherent interaction between matter and an electromagnetic field confined within a resonator structure, and is providing a useful platform for developing concepts in quantum information processing. By using high-quality resonators, a strong coupling regime can be reached experimentally in which atoms coherently exchange a photon with a single light-field mode many times before dissipation sets in. This has led to fundamental studies with both microwave and optical resonators. To meet the challenges posed by quantum state engineering and quantum information processing, recent experiments have focused on laser cooling and trapping of atoms inside an optical cavity. However, the tremendous degree of control over atomic gases achieved with Bose-Einstein condensation has so far not been used for cavity QED. Here we achieve the strong coupling of a Bose-Einstein condensate to the quantized field of an ultrahigh-finesse optical cavity and present a measurement of its eigenenergy spectrum. This is a conceptually new regime of cavity QED, in which all atoms occupy a single mode of a matter-wave field and couple identically to the light field, sharing a single excitation. This opens possibilities ranging from quantum communication to a wealth of new phenomena that can be expected in the many-body physics of quantum gases with cavity-mediated interactions.