Using a systems biology approach, we discovered and dissected a three-way interaction between the immune system, the intestinal epithelium and the microbiota. We found that, in the absence of B cells, or of IgA, and in the presence of the microbiota, the intestinal epithelium launches its own protective mechanisms, upregulating interferon-inducible immune response pathways and simultaneously repressing Gata4-related metabolic functions. This shift in intestinal function leads to lipid malabsorption and decreased deposition of body fat. Network analysis revealed the presence of two interconnected epithelial-cell gene networks, one governing lipid metabolism and another regulating immunity, that were inversely expressed. Gene expression patterns in gut biopsies from individuals with common variable immunodeficiency or with HIV infection and intestinal malabsorption were very similar to those of the B cell-deficient mice, providing a possible explanation for a longstanding enigmatic association between immunodeficiency and defective lipid absorption in humans.