A photoelectric encoder, comprising: a light source; a scale for generating a light-and-dark pattern of light in a first direction along a measurement axis by light irradiated from the light source; and a light-receiving unit for detecting the light-and-dark pattern of light, the light-receiving unit including: a first light-receiving element row (LRL<0>) and a second light-receiving element row LRL<1>) each configured from a plurality of light-receiving elements, the light-receiving elements being arranged in the first direction and configured to detect the light-and-dark pattern of light; and a light-blocking layer configured from a light-blocking portion and a light-transmitting portion formed on a light-receiving surface of each of the light-receiving elements, the light-blocking portion configured to block the light-and-dark pattern of light, and the light-transmitting portion configured to allow transmission of the light-and-dark pattern of light, the first and second light-receiving element rows (LRL<0> and <1>) being disposed staggered in the first direction such that an arrangement pattern of the light-receiving elements in the first and second light-receiving element rows has a pitch which is the same in the first direction and a phase which differs in the first direction, a projection in a second direction orthogonal to the first direction of the light-transmitting portion of the light-blocking layer on the light-receiving surface of the light-receiving element in the first light-receiving element row (LRL<0>) overlaps only the light-blocking portion in the light-blocking layer on the light-receiving surface of the light-receiving element in the second light-receiving element row (LRL<1>), and a width in the first direction of the light-transmitting portion being more than 1/2 of a width in the first direction of the light-receiving surface of the light-receiving element, characterized in that each light receiving surface has formed thereon only one light-transmitting portion, the light-blocking portion sandwiching the one light-transmitting portion in the first direction. a light source; a scale for generating a light-and-dark pattern of light in a first direction along a measurement axis by light irradiated from the light source; and a light-receiving unit for detecting the light-and-dark pattern of light, the light-receiving unit including: a first light-receiving element row (LRL<0>) and a second light-receiving element row LRL<1>) each configured from a plurality of light-receiving elements, the light-receiving elements being arranged in the first direction and configured to detect the light-and-dark pattern of light; and a light-blocking layer configured from a light-blocking portion and a light-transmitting portion formed on a light-receiving surface of each of the light-receiving elements, the light-blocking portion configured to block the light-and-dark pattern of light, and the light-transmitting portion configured to allow transmission of the light-and-dark pattern of light, the first and second light-receiving element rows (LRL<0> and <1>) being disposed staggered in the first direction such that an arrangement pattern of the light-receiving elements in the first and second light-receiving element rows has a pitch which is the same in the first direction and a phase which differs in the first direction, a projection in a second direction orthogonal to the first direction of the light-transmitting portion of the light-blocking layer on the light-receiving surface of the light-receiving element in the first light-receiving element row (LRL<0>) overlaps only the light-blocking portion in the light-blocking layer on the light-receiving surface of the light-receiving element in the second light-receiving element row (LRL<1>), and a width in the first direction of the light-transmitting portion being more than 1/2 of a width in the first direction of the light-receiving surface of the light-receiving element, characterized in that each light receiving surface has formed thereon only one light-transmitting portion, the light-blocking portion sandwiching the one light-transmitting portion in the first direction.