Inflammatory bowel disease (IBD) in humans and animals is associated with bacterial infection and intestinal barrier dysfunction. Cecropin A, an antimicrobial peptide, has antibacterial activity against pathogenic bacteria. However, the effect of cecropin A on intestinal barrier function and its related mechanisms is still unclear. Here, we used porcine jejunum epithelial cells (IPEC-J2) as a model to investigate the effect and mechanism of cecropin A on intestinal barrier function. We found that cecropin A reduced Escherichia coli (E. coli) adherence to IPEC-J2 cells and downregulated mRNA expression of tumor necrosis factor α (TNF-α), interleukin-6 (IL-6), and interleukin-8 (IL-8). Furthermore, cecropin A elevated the transepithelial electrical resistance (TER) value while reducing the paracellular permeability of the IPEC-J2 cell monolayer barrier. Finally, by using Western blotting, immunofluorescence and pathway-specific antagonists, we demonstrated that cecropin A increased ZO-1, claudin-1 and occludin protein expression and regulated membrane distribution and F-actin polymerization by increasing CDX2 expression. We conclude that cecropin A enhances porcine intestinal epithelial cell barrier function by downregulating the mitogen-activated protein kinase (MEK)/extracellular signal-regulated kinase (ERK) pathway. We suggest that cecropin A has the potential to replace antibiotics in the treatment of IBD due to its antibacterial activity on gram-negative bacteria and its enhancement effect on intestinal barrier function.