Why is polyandry such a common mating behaviour when it exposes females to a range of significant fitness costs? Here, we investigated whether polyandry protects females against reduced male fertility caused by thermal stress from heatwave conditions. Sperm production and function are vulnerable to heat, and heatwave conditions are forecast to increase as our climate warms, so we examined these effects on female reproduction and mating behaviour in the flour beetle, Tribolium castaneum, a promiscuous ectotherm model in which fertility is damaged by environmental warming. We tested whether polyandrous matings, or polyandrous sperm stores, protect females against reduced male fertility caused by heatwave conditions, and whether females flexibly adjust their remating behaviour to enable fertility rescue. We found that polyandry protected females against reduced male fertility: monogamous matings with males exposed to heatwave conditions halved female offspring production, but opportunities to mate with five of these males allowed normal female reproductive output. By contrast with this fertility improvement following polyandrous mating opportunities, there was no protective benefit for females already carrying sperm stores from multiple males, which suffered similar heatwave damage within the female tract as monogamous sperm stores. Importantly, female polyandry was flexible to male condition, with females showing greater motivation to remate with new males if their previous mate had been damaged by heatwave exposure, enabling a rapid reproductive rescue. Our results reveal that flexible polyandry enables females to rescue their fertility when male reproductive function is compromised by heatwave conditions, a phenomenon that may become more prevalent under climate change.