Genetic variation for partner quality in mutualisms is an evolutionary paradox. One possible resolution to this puzzle is that there is a tradeoff between partner quality and other fitness-related traits. Here, we tested whether a susceptibility to parasitism is one such tradeoff in the mutualism between legumes and nitrogen-fixing bacteria (rhizobia). We performed two greenhouse experiments with the legume Medicago truncatula. In the first, we inoculated each plant with the rhizobia Ensifer meliloti and with one of 40 genotypes of the parasitic root-knot nematode Meloidogyne hapla. In the second experiment, we inoculated all plants with rhizobia and half of the plants with a genetically variable population of nematodes. Using the number of nematode galls as a proxy for infection severity, we found that plant genotypes differed in susceptibility to nematode infection, and nematode genotypes differed in infectivity. Second, we showed that there was a genetic correlation between the number of mutualistic structures formed by rhizobia (nodules) and the number of parasitic structures formed by nematodes (galls). Finally, we found that nematodes disrupt the rhizobia mutualism: nematode-infected plants formed fewer nodules and had less nodule biomass than uninfected plants. Our results demonstrate that there is genetic conflict between attracting rhizobia and repelling nematodes in Medicago. If genetic conflict with parasitism is a general feature of mutualism, it could account for the maintenance of genetic variation in partner quality and influence the evolutionary dynamics of positive species interactions.

#### Experiment1

Data for experiment 1. To test how rhizobia and nematodes impact fitness in co-infected plants, and to measure genetic variation in nematode infectivity, we used a fractional factorial design with a total of 400 M. truncatula plants from 10 genotypes across 10 blocks. We inoculated each plant with 1 of 40 nematode genotypes. Each block included 4 replicates of each plant genotype and 1 replicate of each nematode genotype, for a total of 40 replicates of each plant genotype and 10 replicates of each nematode genotype. Each nematode genotype inoculated 2 different plant genotypes, for a total of 5 replicates per nematode genotype-plant genotype combination.

#### Experiment2

Data for experiment 2. To measure genetic conflict between attracting rhizobia and repelling nematodes, and to test how parasitic nematodes impact the rhizobia mutualism, we used a split-plot randomized design. Each block contained two treatments: one in which we only inoculated plants with rhizobia, and one in which we inoculated plants with both rhizobia and nematodes. Plants received a total of 400 nematode eggs from a genetically variable nematode inoculum. Each treatment in each block contained one M. truncatula individual from each of 50 genotypes. We replicated this design across 10 blocks (50 plants per treatment per block × 2 treatments × 10 blocks = 1000 plants).

#### GenotypeMeans_NodulesAndGalls

Data used to estimate the genetic correlation between nodule and gall production.To estimate genotype means for gall number, we extracted the conditional modes of the genotype random effect from a model that included fixed effects of root mass and researcher, and random effects of genotype and block. We used estimates of nodulation from the rhizobia-only treatment to estimate the genetic correlation with gall formation. We estimated genotype means for nodule number using a model similar to the gall model, and specified a negative binomial error distribution and allowed for zero inflation in both models. We also estimated the genetic correlation between gall number and the change in nodule number between the two treatments. We estimated genotype means for nodule number in nematode-infected plants using a similar model to the one used to estimate nodule number in the rhizobia-only treatment. We subtracted the genotype mean for nodule number in nematode-infected plants from the genotype mean for nodule number in uninfected plants to calculate the change in nodule number for each genotype.

#### DataAnalysis

This R script contains the code used to run all the analyses presented in our manuscript. It relies on one other script ("checkAssumptions.R") to check statistical assumptions.

#### Check regression assumptions

This script contains functions to check regression assumptions (normality, linearity, homoscedasticity) and calculate variance inflation factors

checkAssumptions.R