Immunomodulatory drugs can inhibit bacterial growth, yet their mechanism of action, spectrum, and clinical relevance remain unknown. Methotrexate (MTX), a first-line rheumatoid arthritis (RA) treatment, inhibits mammalian dihydrofolate reductase (DHFR), but whether it directly impacts gut bacteria is unclear. We show that MTX broadly alters the human gut microbiota. Drug sensitivity varied across strains, but the mechanism of action against DHFR appears conserved between mammalian and bacterial cells. RA patient microbiotas were sensitive to MTX, and changes in gut bacterial taxa and gene family abundance were distinct between responders and non-responders. Transplantation of post-treatment samples into germ-free mice given an inflammatory trigger led to reduced immune activation relative to pre-treatment controls, enabling identification of MTX-modulated bacterial taxa associated with intestinal and splenic immune cells. Thus, conservation in cellular pathways across domains of life can result in broad off-target drug effects on the human gut microbiota with consequences for immune function.