Variants at the ABCB4 or MDR2 locus, which encodes a biliary transport protein, are associated with a spectrum of cholestatic liver diseases. Exacerbation of liver disease has been linked to increased hepatic levels of interleukin (IL) 17, yet the mechanisms of this increase are not understood. We studied mice with disruption of Mdr2 to determine how defects in liver and alteration in the microbiota contribute to production of IL17 by intrahepatic γδ T cells. We performed studies with Mdr2-/- and littermate FVB/NJ (control) mice. IL17 was measured in serum samples by an enzyme-linked immunosorbent assay. Mice were injected with neutralizing antibodies against the γδ T-cell receptor (TCR; anti-γδ TCR) or mouse IL17A (anti-IL17A). Livers were collected and bacteria were identified in homogenates by culture procedures; TCRγδ+ cells were isolated by flow cytometry. Fecal samples were collected from mice and analyzed by 16S ribosomal DNA sequencing. Cells were stimulated with antibodies or bacteria, and cytokine production was measured. We obtained tissues from 10 patients undergoing liver transplantation for primary sclerosing cholangitis or chronic hepatitis C virus infection. Tissues were analyzed for cytokine production by γδ TCR+ cells. Mdr2-/- mice had collagen deposition around hepatic bile ducts and periportal-bridging fibrosis with influx of inflammatory cells and increased serum levels of IL17 compared with control mice. Administration of anti-IL17A reduced hepatic fibrosis. Livers from Mdr2-/- mice had increased numbers of IL17A+ γδTCR+ cells-particularly of IL17A+ Vγ6Jγ1 γδ TCR+ cells. Fecal samples from Mdr2-/- mice were enriched in Lactobacillus, and liver tissues were enriched in Lactobacillus gasseri compared with control mice. Mdr2-/- mice also had increased intestinal permeability. The γδ TCR+ cells isolated from Mdr2-/- livers produced IL17 in response to heat-killed L gasseri. Intraperitoneal injection of control mice with L gasseri led to increased serum levels of IL17 and liver infiltration by inflammatory cells; injection of these mice with anti-γδ TCR reduced serum level of IL17. Intravenous injections of Mdr2-/- mice with anti-γδ TCR reduced fibrosis; liver levels of IL17, and inflammatory cells; and serum levels of IL17. γδTCR+ cells isolated from livers of patients with primary sclerosing cholangitis, but not hepatitis C virus infection, produced IL17. In Mdr2-/- mice, we found development of liver fibrosis and inflammation to require hepatic activation of γδ TCR+ cells and production of IL17 mediated by exposure to L gasseri. This pathway appears to contribute to development of cholestatic liver disease in patients.