Animal behavior is often quantified through subjective, incomplete variables that may mask essential dynamics. Here, we develop a behavioral state space in which the full instantaneous state is smoothly unfolded as a combination of short-time posture dynamics. Our technique is tailored to multivariate observations and extends previous reconstructions through the use of maximal prediction. Applied to high-resolution video recordings of the roundworm C. elegans , we discover a low-dimensional state space dominated by three sets of cyclic trajectories corresponding to the worm’s basic stereotyped motifs: forward, backward, and turning locomotion. In contrast to this broad stereotypy, we find variability in the presence of locally-unstable dynamics, and this unpredictability shows signatures of deterministic chaos: a collection of unstable periodic orbits together with a positive maximal Lyapunov exponent. The full Lyapunov spectrum is symmetric with positive, chaotic exponents driving variability balanced by negative, dissipative exponents driving stereotypy. The symmetry is indicative of damped, driven Hamiltonian dynamics underlying the worm’s movement control.