We analyze the high-resolution X-ray spectrum of Hercules X-1, an intermediate-mass X-ray binary, which was observed with the XMM-Newton Reflection Grating Spectrometer. We measure the elemental abundance ratios by use of spectral models, and we detect material processed through the CNO-cycle. The CNO abundances, and in particular the ratio N/O > 4.0 times solar, provide stringent constraints on the evolution of the binary system. The low and short-on flux states of Her X-1 exhibit narrow line emission from C VI, N VI, N VII, O VII, O VIII, Ne IX, and Ne X ions. The spectra show signatures of photoionization. We measure the electron temperature, quantify photoexcitation in the He alpha lines, and set limits on the location and density of the gas. The recombination lines may originate in the accretion disk atmosphere and corona, or on the X-ray illuminated face of the mass donor (HZ Her). The spectral variation over the course of the 35 d period provides additional evidence for the precession of the disk. During the main-on state, the narrow line emission is absent, but we detect excesses of emission at ~10--15 A, and also near the O VII intercombination line wavelength.