The ability to perceive and respond to harmful conditions is crucial for the survival of any organism. The transcription factor DAF-16/FOXO is central to these responses, relaying distress signals into the expression of stress resistance and longevity promoting genes. However, its sufficiency in fulfilling this complex task has remained unclear. Using C. elegans, we show that DAF-16 does not function alone but as part of a transcriptional regulatory module, together with the transcription factor HLH-30/TFEB. Under harmful conditions, both transcription factors translocate into the nucleus, where they often form a complex, co-occupy target promoters, and co-regulate many target genes. Interestingly though, their synergy is stimulus-dependent: They rely on each other, functioning in the same pathway, to promote longevity or resistance to oxidative stress, but they elicit heat stress responses independently, and they even oppose each other during dauer formation. We propose that this module of DAF-16 and HLH-30 acts by combinatorial gene regulation to relay distress signals into the expression of specific target gene sets, ensuring optimal survival under each given threat.