Herein we present a theoretical study of the reaction of singlet oxygen with histidine performed both in the gas phase and in aqueous solution. The potential energy surface of the reactive system was explored at the B3LYP/cc-pVTZ level of theory and the electronic energies were refined by means of single-point CCSD(T)/cc-pVTZ(-f) calculations. Solvent effects were taken into account by using a solvent continuum model (COSMO) and by adding explicit water molecules. The results show that the first step in the reaction mechanism corresponds to a nearly symmetric Diels-Alder addition of the singlet oxygen molecule to the imidazole ring to yield an endoperoxide, in agreement with experimental evidence. The intermediate formed can evolve along two different reaction paths leading to two isomeric hydroperoxides and, eventually, to open-chain or internally cyclised oxidised products. Water plays a significant role in stabilising the reaction structures by solvation and by acting as a bifunctional catalyst in the elimination/addition reaction steps. Our results explain why substituents at the N1-imidazole ring can hamper the evolution of the initial endoperoxide and result in Gibbs energy barriers in solution similar to those experimentally measured and suggest a likely route to the formation of peptide aggregates during the oxidation of histidine by singlet molecular oxygen.