In this paper, we design a novel MRF framework which is called Non-Local Range Markov Random Field (NLRMRF). The local spatial range of clique in traditional MRF is extended to the non-local range which is defined over the local patch and also its similar patches in a non-local window. Then the traditional local spatial filter is extended to the non-local range filter that convolves an image over the non-local ranges of pixels. In this framework, we propose a gradient-based discriminative learning method to learn the potential functions and non-local range filter bank. As the gradients of loss function with respect to model parameters are explicitly computed, efficient gradient-based optimization methods are utilized to train the proposed model. We implement this framework for image denoising and inpainting, the results show that the learned NLR-MRF model significantly outperforms the traditional MRF models and produces state-of-the-art results.