DNA methylation plays an important role in regulating plant growth, development and gene expression. However, less is known about the response of DNA methyltransferase and demethylase genes to various stresses. In this study, the effects of abiotic stresses on DNA methylation gene expression patterns in tomato seedlings were investigated. Results showed that most tomato DNA methyltransferase and demethylase genes contained stress-related elements. The expression of SlDML1 was significantly induced by cadmium (Cd) and sodium chloride (NaCl) stresses. SlDML2 was more sensitive and reached its maximum value under polyethylene (PEG) stress at 24 h. The expression of SlMET3L was repressed to varying degrees under Cd, NaCl and PEG stresses at 48 h. However, 5-aza-2′-deoxycytidine (5-azadC) treatment decreased the Cd and PEG stress tolerance by down-regulating the expression of DNA methyltransferase except for the SlMET3L, and up-regulating the expression levels of SlDML2, SlDML3 and SlDML4, cadmium transporters (SlHMA5, SlCAX3, and SlACC3) and osmoregulators (SlDREB, SlLEA and SlHSP70). Whereas 5-azadC treatment alleviated the salt stress through up-regulating DNA methyltransferase gene expression, and down-regulating the expression level of SlDML1, SlDML3, and SlDML4, SlHKT1, SlNHX1, and SlSOS1. Collectively, 5-azadC impaired Cd and PEG stress tolerance and enhanced salt stress tolerance by regulating the expression of methylation-related and stress-related genes in tomato seedlings. These results may provide useful information for further analysing function and evolution of DNA methylation methyltransferase and demethylase genes in tomato under stress conditions.