Migrating cells in physiological processes, including development, homeostasis and cancer, encounter structured environments and are forced to overcome physical obstacles. Yet, the dynamics of confined cell migration remains poorly understood, and thus there is a need to study the complex motility of cells in controlled confining microenvironments. Here, we develop two-state micropatterns, consisting of two adhesive sites connected by a thin constriction, in which migrating cells perform repeated stochastic transitions. This minimal system enables us to obtain a large ensemble of single-cell trajectories. From these trajectories, we infer an equation of cell motion, which decomposes the dynamics into deterministic and stochastic contributions in position-velocity phase space. Our results reveal that cells in two-state micropatterns exhibit intricate nonlinear migratory dynamics, with qualitatively similar features for a cancerous (MDA-MB-231) and a non-cancerous (MCF10A) cell line. In both cases, the cells drive themselves deterministically into the thin constriction; a process that is sped up by noise. Interestingly, however, these two cell lines have distinct deterministic dynamics: MDA-MB-231 cells exhibit a limit cycle, while MCF10A cells show excitable bistable dynamics. Our approach yields a conceptual framework that may be extended to understand cell migration in more complex confining environments.