In situ X-ray diffraction (XRD) and transmission electron microscopy (TEM) have been used to investigate many physical science phenomena, ranging from phase transitions, chemical reactions and crystal growth to grain boundary dynamics. A major limitation of in situ XRD and TEM is a compromise that has to be made between spatial and temporal resolution. Here, we report the development of in situ X-ray nanodiffraction to measure high-resolution diffraction patterns from single grains with up to 5 ms temporal resolution. We observed, for the first time, grain rotation and lattice deformation in chemical reactions induced by X-ray photons: Br⁻ + hν → Br + e⁻ and e⁻ + Ag⁺ → Ag⁰. The grain rotation and lattice deformation associated with the chemical reactions were quantified to be as fast as 3.25 rad s⁻¹ and as large as 0.5 Å, respectively. The ability to measure high-resolution diffraction patterns from individual grains with a temporal resolution of several milliseconds is expected to find broad applications in materials science, physics, chemistry and nanoscience.