A photoelectric sensor, comprising: a case comprising a first case member and a second case member disposed opposite to the first case member, wherein a housing space is formed between the first case member and the second case member; a base board disposed in the housing space and mounted with a light projecting part for emitting light and a light receiving part for receiving light, which are separated from each other; a light guide member disposed in the housing space and comprising a light projecting side light guide part guiding light from the light projecting part to outside of the case, and a light receiving side light guide part guiding light from the outside of the case to the light receiving part; and a light shielding member disposed in the housing space, defining a positional relationship between the base board and the light guide member, and shielding light between the light projecting part and the light receiving part, wherein one of the light projecting side light guide part and the light receiving side light guide part extends in a first direction, an axial direction of one of the light projecting part and the light receiving part is identical to the first direction, the other one of the light projecting side light guide part and the light receiving side light guide part extends in a second direction parallel to the first direction with a protrusion thereof inclined with respect to the second direction, an axial direction of the other one of the light projecting part and the light receiving part is parallel to the second direction with an offset, the offset is compensated by the protrusion inclined with respect to the second direction, and the light shielding member comprises a fitting part, into which the one of the light projecting side light guide part and the light receiving side light guide part fits in the axial direction of the one of the light projecting part and the light receiving part, and a contact part that is in contact with the base board in a direction parallel to the first direction. a case comprising a first case member and a second case member disposed opposite to the first case member, wherein a housing space is formed between the first case member and the second case member; a base board disposed in the housing space and mounted with a light projecting part for emitting light and a light receiving part for receiving light, which are separated from each other; a light guide member disposed in the housing space and comprising a light projecting side light guide part guiding light from the light projecting part to outside of the case, and a light receiving side light guide part guiding light from the outside of the case to the light receiving part; and a light shielding member disposed in the housing space, defining a positional relationship between the base board and the light guide member, and shielding light between the light projecting part and the light receiving part, wherein one of the light projecting side light guide part and the light receiving side light guide part extends in a first direction, an axial direction of one of the light projecting part and the light receiving part is identical to the first direction, the other one of the light projecting side light guide part and the light receiving side light guide part extends in a second direction parallel to the first direction with a protrusion thereof inclined with respect to the second direction, an axial direction of the other one of the light projecting part and the light receiving part is parallel to the second direction with an offset, the offset is compensated by the protrusion inclined with respect to the second direction, and the light shielding member comprises a fitting part, into which the one of the light projecting side light guide part and the light receiving side light guide part fits in the axial direction of the one of the light projecting part and the light receiving part, and a contact part that is in contact with the base board in a direction parallel to the first direction.