We investigate a historical experience to measure the long-term effect of malaria on lifespan among infected survivors and identify a factor that mitigates malaria’s effect. Using a sample of Union Army veterans born during the mid-19th century and their lifetime records, we show that exposure to high risk of malaria at birth or in early life substantially shortened their lifespan. The legacy of exposure to malaria is robust while controlling for lifetime socioeconomic and health conditions, fixed effects, and considering selection bias. Additionally, we include the US Colored Troops sample of black veterans to analyze racial differences in the effect of malaria exposure on lifespan. Exposure to malaria did not lead to a shorter lifespan among black veterans. Evidence suggests that genetic immunity to malaria in black veterans might contribute this heterogeneity.