The trillions of microorganisms (microbiota) found within the human gut play a critical role in shaping the immune system, yet these complex microbial communities are also highly sensitive to numerous environmental factors. While much of the focus to date has been on dietary intake, emerging data has begun to suggest that the use of pharmaceutical drugs, even those that are not considered to be antibiotics, can alter the human gut microbiota with unknown consequences for treatment outcomes. Here, we use a combination of in vitro, in vivo, and ex vivo methods to demonstrate that the first-line therapy for rheumatoid arthritis (RA), methotrexate (MTX), has off-target effects on the human gut microbiota, resulting in a significant growth advantage for drug-resistant Firmicutes over the Bacteroidetes, which tend to be more sensitive. Longitudinal analyses of the gut microbiotas of RA patients revealed that MTX-induced shifts in bacterial relative abundance are associated with improved drug response and transplant experiments in gnotobiotic mice show that these shifts lead to reduced inflammation. Together, these results suggest that the mechanism-of-action of non-antibiotic drugs may be due in part to off-target effects on the gut microbiota, while providing a critical first step towards explaining long-standing differences in drug response between patients.