The generation, distribution and control of entanglement across quantum networks is one of the main goals of quantum information science1,2. In previous studies, hyperfine ground states of single atomsor atomic ensembles have been entangled with spontaneously emitted light3–6. The probabilistic character of the spontaneous emission process leads to long entanglement generation times, limiting realized network implementations to just two nodes7–10. The success probability for atom–photon entanglement protocols can be increased by confining a single atom in a high-finesse optical cavity11,12. Alternatively, quantum networks with superior scaling properties could be achieved using entanglement between light fields and atoms in quantum superpositions of the ground and highly excited (Rydberg) electronic states2,13,14. Here we report the generation of such entanglement. The dephasing of the optical atomic coherence is inhibited by state-insensitive confinement of both the ground and Rydberg states of an ultracold atomic gas in an optical lattice15. Our results pave the way for functional, many-node quantum networks capable of deterministic quantum logic operations between long-lived atomic memories.