Vitamin D (VD) is a steroid hormone that is widely known to play an important role in maintaining mineral homeostasis, and regulating various physiological functions. Our previous results demonstrated that the interruption of VD metabolism caused hyperglycemia in zebrafish. In the present study we further explored the mechanism that VD regulates glucose metabolism by maintaining intestinal homeostasis in zebrafish. Our results showed that the expression of several peptide hormones including gastric inhibitory peptide, peptide YY, and fibroblast growth factor 19 in the intestine decreased, while the expression of sodium glucose cotransporter-1 and gcg was increased in the intestine of the zebrafish fed with the VD3-deficient diet. Consistently, similar results were obtained in cyp2r1−/− zebrafish, in which endogenous VD metabolism is blocked. Furthermore, the results obtained from germ-free zebrafish exhibited that VD-regulated glucose metabolism was partly dependent on the microbiota in zebrafish. Importantly, the transplantation of gut microbiota collected from cyp2r1−/− zebrafish to germ-free zebrafish led to hyperglycemic symptoms in the fish, which were associated with the altered structure and functions of the microbiota in cyp2r1−/− zebrafish. Interestingly, the treatments with acetate or Cetobacterium somerae, a potent acetate producer, lowered the glucose contents whereas augmented insulin expression in zebrafish larvae. Notably, acetate supplementation alleviated hyperglycemia in cyp2r1−/− zebrafish and other diabetic zebrafish. In conclusion, our study has demonstrated that VD modulates the gut microbiota-SCFAs-gastrointestinal hormone axis, contributing to the maintenance of glucose homeostasis.