Background Although studies have provided estimates of premature deaths attributable to either heat or cold in selected countries, none has so far offered a systematic assessment across the whole temperature range in populations exposed to different climates. We aimed to quantify the total mortality burden attributable to non-optimum ambient temperature, and the relative contributions from heat and cold and from moderate and extreme temperatures. Methods We collected data for 384 locations in Australia, Brazil, Canada, China, Italy, Japan, South Korea, Spain, Sweden, Taiwan, Thailand, UK, and USA. We fitted a standard time-series Poisson model for each location, controlling for trends and day of the week. We estimated temperature-mortality associations with a distributed lag non-linear model with 21 days of lag, and then pooled them in a multivariate metaregression that included country indicators and temperature average and range. We calculated attributable deaths for heat and cold, defined as temperatures above and below the optimum temperature, which corresponded to the point of minimum mortality, and for moderate and extreme temperatures, defined using cutoffs at the 2·5th and 97·5th temperature percentiles. Findings We analysed 74 225 200 deaths in various periods between 1985 and 2012. In total, 7·71% (95% empirical CI 7·43-7·91) of mortality was attributable to non-optimum temperature in the selected countries within the study period, with substantial differences between countries, ranging from 3·37% (3·06 to 3·63) in Thailand to 11·00% (9·29 to 12·47) in China. The temperature percentile of minimum mortality varied from roughly the 60th percentile in tropical areas to about the 80-90th percentile in temperate regions. More temperature-attributable deaths were caused by cold (7·29%, 7·02-7·49) than by heat (0·42%, 0·39-0·44). Extreme cold and hot temperatures were responsible for 0·86% (0·84-0·87) of total mortality. Interpretation Most of the temperature-related mortality burden was attributable to the contribution of cold. The effect of days of extreme temperature was substantially less than that attributable to milder but non-optimum weather. This evidence has important implications for the planning of public-health interventions to minimise the health consequences of adverse temperatures, and for predictions of future effect in climate-change scenarios. Funding UK Medical Research Council.