Electronic phases with symmetry properties matching those of conventional liquid crystals have recently been discovered in transport experiments on semiconductor heterostructures and metal oxides at milli-Kelvin temperatures. We report the spontaneous onset of a onedimensional, incommensurate modulation of the spin system in the high-temperature superconductor YBa2Cu3O6.45 upon cooling below ~150 K, while static magnetic order is absent above 2 K. The evolution of this modulation with temperature and doping parallels that of the in-plane anisotropy of the resistivity, indicating an electronic nematic phase that is stable over a wide temperature range. The results suggest that soft spin fluctuations are a microscopic route towards electronic liquid crystals, and nematic order can coexist with high-temperature superconductivity in underdoped cuprates.