Considerable efforts have been recently devoted to combining ultracold atoms and nanophotonic devices to obtain not only better scalability and figures of merit than in free-space implementations, but also new paradigms for atom-photon interactions. Dielectric waveguides offer a promising platform for such integration because they enable tight transverse confinement of the propagating light, strong photon-atom coupling in single-pass configurations and potentially long-range atom-atom interactions mediated by the guided photons. However, the preparation of non-classical quantum states in such atom-waveguide interfaces has not yet been realized. Here, by using arrays of individual caesium atoms trapped along an optical nanofibre, we observe a single collective atomic excitation coupled to a nanoscale waveguide. The stored collective entangled state can be efficiently read out with an external laser pulse, leading to on-demand emission of a single photon into the guided mode. We characterize the emitted single photon via the suppression of the two-photon component and confirm the single character of the atomic excitation, which can be retrieved with an efficiency of about 25%. Our results demonstrate a capability that is essential for the emerging field of waveguide quantum electrodynamics, with applications to quantum networking, quantum nonlinear optics and quantum many-body physics.