Dysregulated host responses to infection can lead to organ dysfunction and sepsis, causing millions of global deaths each year. To alleviate this burden, improved prognostication and biomarkers of response are urgently needed. We investigated the use of whole-blood transcriptomics for stratification of patients with severe infection by integrating data from 3149 samples from patients with sepsis due to community-acquired pneumonia or fecal peritonitis admitted to intensive care and healthy individuals into a gene expression reference map. We used this map to derive a quantitative sepsis response signature (SRSq) score reflective of immune dysfunction and predictive of clinical outcomes, which can be estimated using a 7- or 12-gene signature. Last, we built a machine learning framework, SepstratifieR, to deploy SRSq in adult and pediatric bacterial and viral sepsis, H1N1 influenza, and COVID-19, demonstrating clinically relevant stratification across diseases and revealing some of the physiological alterations linking immune dysregulation to mortality. Our method enables early identification of individuals with dysfunctional immune profiles, bringing us closer to precision medicine in infection.