Background: Low carbohydrate diets, which restrict carbohydrate in favour of increased protein or fat intake, or both, are a popular weight-loss strategy. However, the long-term effect of carbohydrate restriction on mortality is controversial and could depend on whether dietary carbohydrate is replaced by plant-based or animal-based fat and protein. We aimed to investigate the association between carbohydrate intake and mortality. Methods: We studied 15 428 adults aged 45–64 years, in four US communities, who completed a dietary questionnaire at enrolment in the Atherosclerosis Risk in Communities (ARIC) study (between 1987 and 1989), and who did not report extreme caloric intake (<600 kcal or >4200 kcal per day for men and <500 kcal or >3600 kcal per day for women). The primary outcome was all-cause mortality. We investigated the association between the percentage of energy from carbohydrate intake and all-cause mortality, accounting for possible non-linear relationships in this cohort. We further examined this association, combining ARIC data with data for carbohydrate intake reported from seven multinational prospective studies in a meta-analysis. Finally, we assessed whether the substitution of animal or plant sources of fat and protein for carbohydrate affected mortality. Findings: During a median follow-up of 25 years there were 6283 deaths in the ARIC cohort, and there were 40 181 deaths across all cohort studies. In the ARIC cohort, after multivariable adjustment, there was a U-shaped association between the percentage of energy consumed from carbohydrate (mean 48·9%, SD 9·4) and mortality: a percentage of 50–55% energy from carbohydrate was associated with the lowest risk of mortality. In the meta-analysis of all cohorts (432 179 participants), both low carbohydrate consumption (<40%) and high carbohydrate consumption (>70%) conferred greater mortality risk than did moderate intake, which was consistent with a U-shaped association (pooled hazard ratio 1·20, 95% CI 1·09–1·32 for low carbohydrate consumption; 1·23, 1·11–1·36 for high carbohydrate consumption). However, results varied by the source of macronutrients: mortality increased when carbohydrates were exchanged for animal-derived fat or protein (1·18, 1·08–1·29) and mortality decreased when the substitutions were plant-based (0·82, 0·78–0·87). Interpretation: Both high and low percentages of carbohydrate diets were associated with increased mortality, with minimal risk observed at 50–55% carbohydrate intake. Low carbohydrate dietary patterns favouring animal-derived protein and fat sources, from sources such as lamb, beef, pork, and chicken, were associated with higher mortality, whereas those that favoured plant-derived protein and fat intake, from sources such as vegetables, nuts, peanut butter, and whole-grain breads, were associated with lower mortality, suggesting that the source of food notably modifies the association between carbohydrate intake and mortality. Funding: National Institutes of Health.