We report an association between X-linked immunodeficiency with hyper-IgM (XHIM) and carcinomas affecting the liver, pancreas, biliary tree, and associated neuroectodermal endocrine cells. The tumors were fatal in eight of nine cases and in most instances were preceded by chronic cholangiopathy and/or cirrhosis. An additional group of subjects with XHIM had chronic inflammation of the liver or bile ducts but no malignancy. Many patients with XHIM were infected with cryptosporidia. CD40 is normally expressed on regenerating or inflammed bile duct epithelium. A CD40+ hepatocellular carcinoma cell line, HepG2, susceptible to cryptosporidia and CMV infection became resistant when cell surface CD40 was cross-linked by a CD40 ligand fusion protein. Apoptosis was triggered in HepG2 cells if protein synthesis was blocked by cycloheximide or if the cells were infected by cryptosporidia. Ligation of CD40 on biliary epithelium may contribute to defense against infection by intracellular pathogens. We propose that the CD40 ligand mutations that cause XHIM deprive the biliary epithelium of one line of defense against intracellular pathogens and that malignant transformation in the biliary tree follows chronic infection or inflammation. The resulting tumors may then progress without check by an effective immune response. Patients with XHIM who have abnormal liver function tests should be considered at increased risk for cholangiopathy or malignancy.