An image sensor comprising pixels each includes, an photoelectric conversion unit, a first inner-layer lens, a second inner-layer lens, and an on-chip microlens. A light-shielding wall around the second inner-layer lens is provided between adjacent pixels. A first positional difference between center positions of the first inner-layer lens and the photoelectric conversion unit, a second positional difference between center positions of the second inner-layer lens and the photoelectric conversion unit, and a third positional difference between center positions of the on-chip microlens and the photoelectric conversion unit satisfy: the second positional difference<the first positional difference<the third positional difference.