Many threats to biodiversity cannot be eliminated; for example, invasive pathogens may be ubiquitous. Chytridiomycosis is a fungal disease that has spread worldwide, driving at least 90 amphibian species to extinction, and severely affecting hundreds of others. Once the disease spreads to a new environment, it is likely to become a permanent part of that ecosystem. To enable coexistence with chytridiomycosis in the field, we devised an intervention that exploits host defences and pathogen vulnerabilities. Here we show that sunlight-heated artificial refugia attract endangered frogs and enable body temperatures high enough to clear infections, and that having recovered in this way, frogs are subsequently resistant to chytridiomycosis even under cool conditions that are optimal for fungal growth. Our results provide a simple, inexpensive and widely applicable strategy to buffer frogs against chytridiomycosis in nature. The refugia are immediately useful for the endangered species we tested and will have broader utility for amphibian species with similar ecologies. Furthermore, our concept could be applied to other wildlife diseases in which differences in host and pathogen physiologies can be exploited. The refugia are made from cheap and readily available materials and therefore could be rapidly adopted by wildlife managers and the public. In summary, habitat protection alone cannot protect species that are affected by invasive diseases, but simple manipulations to microhabitat structure could spell the difference between the extinction and the persistence of endangered amphibians.