To improve the accuracy of stereo matching in low-textured or depth discontinuous regions of images, a new method using edge-constrained iterative cost aggregation is proposed in this paper. Firstly, a bilateral diffusion is used as the preprocessing to reduce inconsistency in the matching direction, which can make the follow-up matching more reliable. Secondly, a matching cost function that combines both color and edge is adopted, and a two-step iterative cost aggression based on the minimum spanning tree (MST) is then proposed. In the first cost aggregation, to avoid accumulation of small weights happened in low-textured regions, an enhanced weight function with coefficient adjustment is presented. And in the second cost aggregation, to appropriately provide weights to neighbors, an edge constraint is introduced. The edge information used in the second aggregation is produced by the random forest method from the disparity map obtained in the first cost aggregation. Left-right consistency check and epipolar constraint are both adopted to further eliminate false edge points. Finally, the disparity refinement is utilized to optimize the disparity map. The proposed method is conducted on Middlebury v.2 data set. Experimental results demonstrate that the proposed method can achieve higher matching accuracy, compared with other five state-of-art methods.