Generation of pancreatic β cells from human pluripotent stem cells (hPSCs) holds promise as a cell replacement therapy for diabetes. In this study, we establish a link between the state of the actin cytoskeleton and the expression of pancreatic transcription factors that drive pancreatic lineage specification. Bulk and single-cell RNA sequencing demonstrated that different degrees of actin polymerization biased cells toward various endodermal lineages and that conditions favoring a polymerized cytoskeleton strongly inhibited neurogenin 3-induced endocrine differentiation. Using latrunculin A to depolymerize the cytoskeleton during endocrine induction, we developed a two-dimensional differentiation protocol for generating human pluripotent stem-cell-derived β (SC-β) cells with improved in vitro and in vivo function. SC-β cells differentiated from four hPSC lines exhibited first- and second-phase dynamic glucose-stimulated insulin secretion. Transplantation of islet-sized aggregates of these cells rapidly reversed severe preexisting diabetes in mice at a rate close to that of human islets and maintained normoglycemia for at least 9 months.