A three-grating type photoelectric encoder includes a second grating (20) formed on a scale and first and third gratings (22, 31) disposed on a side of a detector. A part of at least the first grating (22) is shifted in a direction of a measurement axis by P/(2n) (wherein P is a grating pitch, n is the order of a harmonic component to be removed) in order to remove a harmonic component of the nth order. This encoder can be improved with high accuracy by removing harmonic components without increasing manufacturing costs.