The mucosal barrier of vertebrates comprises a unique array of physical elements and bioactive molecules that act in concert to protect the host against pathogens. Vitamin D (VD), an essential nutrient for animals, along with its receptor (VDR), plays a major role in immunity. However, the correlation between VD/VDR and the mucosal barrier system remains unclear. Here, we employed the fish gill as a model and evaluated the role of VD as a dietary supplement in modifying this typical mucosal barrier system. Varies levels of VD (15.2, 364.3, 782.5, 1167.9, 1573.8, and 1980.1 IU/kg) were formulated and fed to grass carp (Ctenopharyngodon idella) for 70 d. Subsequently, fish were challenged with Flavobacterium columnare, a pathogen in epithelial tissues. Following infection, dietary VD alleviated gill rot and damage caused by F. columnare. Further investigations demonstrated that VD improved physical barrier function by elevating the antioxidant capacity and tight junction barriers, and moderated excessive apoptosis. The promoted physical barrier function was related to nuclear factor E2-related factor 2 and myosin light-chain kinase signaling. Additionally, VD treatment enhanced the immune barrier function by boosting disease resistance, producing antibacterial compounds and immunoglobulins, downregulating pro-inflammatory cytokines, and upregulating the gene expression of anti-inflammatory cytokines, which correlated with nuclear factor kappa B and the target of rapamycin signaling pathways. Thus, VD strengthened pathogen defenses in the gill mucosal barrier system. This finding supports the rationale for VD intervention in infectious diseases and will be critical for the viability of sustainable practices in aquaculture.