Emerging fungal pathogens pose a greater threat to biodiversity than any other parasitic group1, causing declines of many taxa, including bats, corals, bees, snakes and amphibians1,2,3,4. Currently, there is little evidence that wild animals can acquire resistance to these pathogens5. Batrachochytrium dendrobatidisis a pathogenic fungus implicated in the recent global decline of amphibians6. Here we demonstrate that three species of amphibians can acquire behavioural or immunological resistance toB. dendrobatidis. Frogs learned to avoid the fungus after just oneB. dendrobatidisexposure and temperature-induced clearance. In subsequent experiments in whichB. dendrobatidisavoidance was prevented, the number of previous exposures was a negative predictor ofB. dendrobatidisburden on frogs andB. dendrobatidis-induced mortality, and was a positive predictor of lymphocyte abundance and proliferation. These results suggest that amphibians can acquire immunity toB. dendrobatidisthat overcomes pathogen-induced immunosuppression7,8,9and increases their survival. Importantly, exposure to dead fungus induced a similar magnitude of acquired resistance as exposure to live fungus. Exposure of frogs toB. dendrobatidisantigens might offer a practical way to protect pathogen-naive amphibians and facilitate the reintroduction of amphibians to locations in the wild whereB. dendrobatidispersists. Moreover, given the conserved nature of vertebrate immune responses to fungi5and the fact that many animals are capable of learning to avoid natural enemies10, these results offer hope that other wild animal taxa threatened by invasive fungi might be rescued by management approaches based on herd immunity.