The rapid development of biotechnology makes it possible to explore genome-wide DNA methylation mapping which has been demonstrated to be related to diseases including cancer. However, it also posts substantial challenges in identifying biologically meaningful methylation pattern changes. Several algorithms have been proposed to detect differential methylation events, such as differentially methylated CpG sites and differentially methylated regions. However, the intrinsic dependency of the CpG sites in a neighboring area has not yet been fully considered. In this paper, we propose a novel method for the identification of differentially methylated genes in a Markov random field-based Bayesian framework. Specifically, we use Markov random field to model the dependency of the neighboring CpG sites, and then estimate the differential methylation score of the CpG sites in a Bayesian framework through a sampling scheme. Finally, the differential methylation statuses of the genes are determined by the estimated scores of the involved CpG sites. In addition, significance test is conducted to assess the significance of the identified differentially methylated genes. Experimental results on both synthetic data and real data demonstrate the effectiveness of the proposed method in identifying genes with differential methylation patterns under different conditions.