Determining whether liquid water exists on the Martian surface is central to understanding the hydrologic cycle and potential for extant life on Mars. Recurring slope lineae, narrow streaks of low reflectance compared to the surrounding terrain, appear and grow incrementally in the downslope direction during warm seasons when temperatures reach about 250-300 K, a pattern consistent with the transient flow of a volatile species. Brine flows (or seeps) have been proposed to explain the formation of recurring slope lineae, yet no direct evidence for either liquid water or hydrated salts has been found. Here we analyse spectral data from the Compact Reconnaissance Imaging Spectrometer for Mars instrument onboard the Mars Reconnaissance Orbiter from four different locations where recurring slope lineae are present. We find evidence for hydrated salts at all four locations in the seasons when recurring slope lineae are most extensive, which suggests that the source of hydration is recurring slope lineae activity. The hydrated salts most consistent with the spectral absorption features we detect are magnesium perchlorate, magnesium chlorate and sodium perchlorate. Our findings strongly support the hypothesis that recurring slope lineae form as a result of contemporary water activity on Mars.