Abstract Enterotoxigenic Escherichia coli (ETEC) F4 secretes enterotoxins and invades the small intestine, which damages the gut barrier function and stimulates the immune reactions characterized by inflammation. In the current study, the effects of B. licheniformis HG76 on gut health were evaluated with ETEC F4-induced IPEC-J2 cells and weaned piglets. The B. licheniformis HG76 was isolated from cecal contents of Rhode Island Red laying hens raised without using antibiotics. The results from the in vitro study showed that the ETEC F4 infection significantly induced IPEC-J2 cell death, and this effect was significantly attenuated by B. licheniformis HG76 treatment (P < 0.05). The gene expressions of zona occludens (ZO1) and tumor necrosis factor (TNF)-α were significantly increased during ETEC F4 infection with B. licheniformis HG76 treatment (P < 0.05). Meanwhile, the ETEC F4 infection significantly increased the mRNA abundance of toll-like receptors (TLR2, TLR4, and TLR5) (P < 0.05), but the B. licheniformis HG76 treatment alleviated this increase. For the in vivo study, 28 weaned piglets susceptible to ETEC F4 at 28 d of age were individually allotted to four experimental groups: NNC: unchallenged control group; NC: challenged control group; PC: antibiotic group (80 mg·kg-1 of avilamycin); and HG76: Bacillus group (1.0 × 109 CFU kg-1 diet of B. licheniformis HG76). The in vivo results showed during the post-challenge phase, ETEC F4 infection decreased average daily gain (ADG) and increased the severity of diarrhea at 44 h post-inoculum (hpi), respectively, in the NC group compared with the NNC group (P < 0.05). In addition, the infection decreased the villus height (VH) in the duodenum of pigs from the NC, PC and HG76 groups compared with the NNC group. The VH of jejunum and ileum in the pigs from the HG76 group were higher than other groups (P < 0.05). There was an increase (P < 0.05) of crypt depth (CD) in the jejunum and ileum of pigs from the HG76 group compared with those from the NNC group. The pigs in the NNC group had the greatest duodenal VH:CD ratio, but the least ileal VH:CD ratio among all the treatment groups. The Vmax value of sucrase in the HG76 group was greater than the NNC group (P < 0.05). When compared with the NC group, the relative mRNA abundance of interleukin 6 (IL6) was increased in the PC group (P < 0.05). In summary, these results suggest that B. licheniformis HG76 can protect the intestinal cells from ETEC F4 infection by inhibiting inflammation and maintaining barrier integrity, and the supplementation of B. licheniformis HG76 can improve the gut development and increase the digestive enzyme activity of ETEC F4 challenged piglets.