In order to reduce an error component of a detected waveform and enable high-accuracy position detection, there is provided an optical encoder, in which a transmittance distribution or a reflectance distribution provided in a scale track in a displacement scale has a first modulation period and a second modulation period in a scale displacement direction, the light receiving element array is arranged to detect a first signal group including two-phase signals, relative phases of which are reversed, in the first modulation period and a second signal group including two-phase signals, relative phases of which are reversed, in the second modulation period, first position information in the first modulation period is detected from the first signal group, and second position information in the second modulation period is detected from the second signal group, and the second modulation period is an odd multiple of the first modulation period.