In recent work in cognitive science, it has been proposed that cognition is a self-organizing, dynamical system. However, capturing the real-time dynamics of cognition has been a formidable challenge. Furthermore, it has been unclear whether dynamics could effectively address the emergence of abstract concepts (e.g., language, mathematics). Here, we provide evidence that a quintessentially cognitive phenomenon-the spontaneous discovery of a mathematical relation-emerges through self-organization. Participants solved a series of gear-system problems while we tracked their eye movements. They initially solved the problems by manually simulating the forces of the gears but then spontaneously discovered a mathematical solution. We show that the discovery of the mathematical relation was predicted by changes in entropy and changes in power-law behavior, two hallmarks of phase transitions. Thus, the present study demonstrates the emergence of higher order cognitive phenomena through the nonlinear dynamics of self-organization.