Therapeutic antibodies that block the programmed death-ligand 1 (PD-L1)/programmed death-1 (PD-1) pathway can induce robust and durable responses in patients with various cancers, including metastatic urothelial cancer (mUC) 1–5 . However, these responses only occur in a subset of patients. Elucidating the determinants of response and resistance is key to improving outcomes and developing new treatment strategies. Here, we examined tumours from a large cohort of mUC patients treated with an anti–PD-L1 agent (atezolizumab) and identified major determinants of clinical outcome. Response was associated with CD8+ T-effector cell phenotype and, to an even greater extent, high neoantigen or tumour mutation burden (TMB). Lack of response was associated with a signature of transforming growth factor β (TGF-β) signalling in fibroblasts, particularly in patients with CD8+ T cells that were excluded from the tumour parenchyma and instead found in the fibroblast- and collagen-rich peritumoural stroma—a common phenotype among patients with mUC. Using a mouse model that recapitulates this immune excluded phenotype, we found that therapeutic administration of a TGF-β blocking antibody together with anti–PD-L1 reduced TGF-β signalling in stromal cells, facilitated T cell penetration into the centre of the tumour, and provoked vigorous anti-tumour immunity and tumour regression. Integration of these three independent biological features provides the best basis for understanding outcome in this setting and suggests that TGF-β shapes the tumour microenvironment to restrain anti-tumour immunity by restricting T cell infiltration.