XRD is based on the principle of Bragg's Law, which relates the wavelength of electromagnetic radiation to the diffraction angle and the lattice spacing in a crystalline sample. When X-rays hit a crystal, they are diffracted in specific directions. By measuring these angles and the corresponding intensities, one can calculate the spacing between planes of atoms in the crystal.