Abstract Background Intestinal metaplasia (IM) is a premalignant lesion associated with gastric cancer. Both animal and clinical studies have revealed that bile acid reflux and subsequent chronic inflammation are key causal factors of IM. Previous studies indicated that SOX2, the key transcription factor in gastric differentiation, was downregulated during IM development while CDX2, the pivotal intestine-specific transcription factor was upregulated significantly. However, it remains unclear whether the downregulation of SOX2 promotes gastric IM emergence or is merely a concomitant phenomenon. In addition, the underlying mechanisms of SOX2 downregulation during IM development are unclear. Methods Gastric cell lines were treated with deoxycholic acid (DCA) in a dose-dependent manner. The expression of CDX2 and miR-21 in gastric tissue microarray were detected by immunohistochemistry and in situ hybridization. Coimmunoprecipitation and immunofluorescence were performed to ascertain the interaction of SOX2 and CDX2. Luciferase reporter assays were used to detect the transcriptional activity of CDX2, and confirm miR-21 binding to SOX2 3′-UTR. The protein level of SOX2, CDX2 and downstream IM-specific genes were investigated using western blotting. mRNA level of miR-21, SOX2, CDX2 and downstream IM-specific genes were detected by qRT-PCR. Results Bile acid treatment could suppress SOX2 expression and simultaneously induce expression of CDX2 in gastric cell lines. Furthermore, we demonstrated that SOX2 overexpression could significantly inhibit bile acid- and exogenous CDX2-induced IM-specific gene expression, including KLF4, cadherin 17 and HNF4α expression. In contrast, SOX2 knockdown had the opposite effect. A dual-luciferase reporter assay demonstrated that SOX2 overexpression could significantly suppress CDX2 transcriptional activity in HEK293T cells. CDX2 and SOX2 could form protein complexes in the nucleus. In addition, bile acid induced the expression of miR-21. The inhibition of SOX2 in bile acid-treated gastric cell lines was rescued by miR-21 knockdown. Conclusions These findings suggested that SOX2 can interfere with the transcriptional activity of CDX2 in bile acid-induced IM and that miR-21 might play a key role in this process, which shed new lights in the prevention of gastric cancer.