In this Letter, we show that a Shack-Hartmann wavefront sensor can be used for the quantitative measurement of the specimen optical path difference (OPD) in an ordinary incoherent optical microscope, if the spatial coherence of the illumination light in the plane of the specimen is larger than the microscope resolution. To satisfy this condition, the illumination numerical aperture should be smaller than the numerical aperture of the imaging lens. This principle has been successfully applied to build a high-resolution reference-free instrument for the characterization of the OPD of micro-optical components and microscopic biological samples. © 2017 Optical Society of America.