The built environment can influence human health, but the available evidence is modest and almost entirely from urban communities in high-income countries. Here we aimed to analyse built environment characteristics and their associations with obesity in urban and rural communities in 21 countries at different development levels participating in the Prospective Urban and Rural Epidemiology (PURE) Study. Photographs were acquired with a standardised approach. We used the previously validated Environmental Profile of a Community's Health photo instrument to evaluate photos for safety, walkability, neighbourhood beautification, and community disorder. An integrated built environment score (ie, a minimum of 0 and a maximum of 20) was used to summarise this evaluation across built environment domains. Associations between built environment characteristics, separately and combined in the integrated built environment score, and obesity (ie, a BMI >30kg/m2) were assessed using multilevel regression models, adjusting for individual, household, and community confounding factors. Attenuation in the associations due to walking was examined. Analyses include 143 338 participants from 530 communities. The mean integrated built environment score was higher in high-income countries (13·3, SD 2·8) compared with other regions (10·1, 2·5) and urban communities (11·2, 3·0). More than 60% of high-income country communities had pedestrian safety features (eg, crosswalks, sidewalks, and traffic signals). Urban communities outside high-income countries had higher rates of sidewalks (176 [84%] of 209) than rural communities (59 [28%] of 209). 15 (5%) of 290 urban communities had bike lanes. Litter and graffiti were present in 372 (70%) of 530 communities, and poorly maintained buildings were present in 103 (19%) of 530. The integrated built environment score was significantly associated with reduced obesity overall (relative risk [RR] 0·58, 95% CI 0·35-0·93; p=0·025) for high compared with low scores and for increasing trend (0·85, 0·78-0·91; p<0·0001). The trends were statistically significant in urban (0·85, 0·77-0·93; p=0·0007) and rural (0·87, 0·78-0·97; p=0·015) communities. Some built environment features were associated with a lower prevalence of obesity: community beautification RR 0·75 (95% CI 0·61-0·92; p=0·0066); bike lanes RR 0·58 (0·45-0·73; p<0·0001); pedestrian safety RR 0·75 (0·62-0·90; p=0·0018); and traffic signals RR 0·68 (0·52-0·89; p=0·0055). Community disorder was associated with a higher prevalence of obesity (RR 1·48, 95% CI 1·17-1·86; p=0·0010). Community built environment features recorded in photographs, including bike lanes, pedestrian safety measures, beautification, traffic density, and disorder, were related to obesity after adjusting for confounders, and stronger associations were found in urban than rural communities. The method presents a novel way of assessing the built environment's potential effect on health. Population Health Research Institute, Hamilton Health Sciences Research Institute, Heart and Stroke Foundation of Ontario, Canadian Institutes of Health Research's Strategy for Patient Oriented Research, Ontario Support Unit, Ontario Ministry of Health and Long-Term Care, AstraZeneca, Sanofi-Aventis, Boehringer Ingelheim, Servier, and GlaxoSmithKline.