A histogram-based matching algorithm for stereo images captured under different illumination conditions is proposed in this work. The cumulative histogram of an image represents the ranks of relative pixel brightness, which are robust to illumination changes. Therefore, we design the matching cost based on the similarity of the cumulative histograms of stereo images. As an optional mode, the proposed algorithm can evaluate the histograms for foreground objects and the background separately to alleviate occlusion artifacts. To determine the disparity of each pixel, the proposed algorithm adaptively aggregates matching costs based on the color similarity and the geometric proximity of neighboring pixels. Then, it refines false disparities at occluded pixels using more reliable disparities of non-occluded pixels. Experimental results demonstrate that the proposed algorithm provides higher quality disparity maps than the conventional methods under varying illumination conditions.