Anti-programmed death 1 (αPD1) immune checkpoint blockade is used in combination for cancer treatment but associated with cardiovascular toxicity. Leflunomide (Lef) can suppress the growth of several tumor and mitigate cardiac remodeling in mice. However, the role of Lef in αPD1-induced cardiotoxicity remains unclear. Here, we report that Lef treatment inhibits αPD1-related cardiotoxicity without compromising the efficacy of αPD1-mediated immunotherapy. Lef changes community structure of gut microbiota in αPD1-treated melanoma-bearing mice. Moreover, mice receiving microbiota transplants from Lef+αPD1-treated melanoma-bearing mice have better cardiac function compared to mice receiving transplants from αPD1-treated mice. Mechanistically, we analyze metabolomics and identify indole-3-propionic acid (IPA), which protects cardiac dysfunction in αPD1-treated mice. IPA can directly bind to the aryl hydrocarbon receptor and promote phosphoinositide 3-kinase expression, thus curtailing the cardiomyocyte response to immune injury. Our findings reveal that Lef mitigates αPD1-induced cardiac toxicity in melanoma-bearing mice through modulation of the microbiota-IPA-heart axis. The role of Leflunomide in αPD1-induced cardiotoxicity remains unclear. Here, the authors show that leflunomide mitigates αPD1-induced cardiac toxicity in melanoma-bearing mice through modulation of the microbiota-indole-3-propionic acid-heart axis.