Type 2 diabetes (T2D) is characterized by insulin resistance and impaired insulin secretion, but the mechanisms underlying insulin secretion failure are not completely understood. Here, we show that a set of co-expressed genes, which is enriched for genes with islet-selective open chromatin, is associated with T2D. These genes are perturbed in T2D and have a similar expression pattern to that of dedifferentiated islets. We identify Sox5 as a regulator of the module. Sox5 knockdown induces gene expression changes similar to those observed in T2D and diabetic animals and has profound effects on insulin secretion, including reduced depolarization-evoked Ca2+-influx and β-cell exocytosis. SOX5 overexpression reverses the expression perturbations observed in a mouse model of T2D, increases the expression of key β-cell genes and improves glucose-stimulated insulin secretion in human islets from donors with T2D. We suggest that human islets in T2D display changes reminiscent of dedifferentiation and highlight SOX5 as a regulator of β-cell phenotype and function.