It is well-known that the minimum spanning tree (MST) is widely used in image segment, edge-preserving filtering, and stereo matching. However, the non-local (NL) filter based on the MST generally results in overly smooth images, since it ignores spatial affinity. In this paper, we propose a new spatial minimum spanning tree filter (SMSTF) to improve the performance of the NL filter by designing a spatial MST to avoid over-smoothing problems, by introducing recursive techniques to implement the filtering process. The SMSTF has the advantages that: (1) the kernel of our filter considers spatial affinity and similarity of intensity; (2) The size of the filter kernel is the entire image domain; (3) the complexity of the SMSTF is linear to the number of image pixels. For these reasons, our filter achieves excellent edge-preserving results. Extensive experiments demonstrate the versatility of the proposed method in a variety of image processing and computer vision tasks, including edge-preserving smoothing, stylization, colorization, and stereo matching.