The wind-driven double-gyre circulation in a rectangular basin goes through several dynamical regimes as the amount of lateral friction is decreased. This paper studies the transition to irregular flow in the double-gyre circulation by applying dynamical systems methodology to a quasi-geostrophic, equivalent-barotropic model with a 10-km resolution. The origin of the irregularities, in space and time, is the occurrence of homoclinic bifurcations that involve phase-space behavior far from stationary solutions. The connection between these homoclinic bifurcations and earlier transitions, which occur at larger lateral friction, is explained. The earlier transitions, such as pitchfork and asymmetric Hopf bifurcation, only involve the nonlinear saturation of linear instabilities, while the homoclinic bifurcations are associated with genuinely nonlinear behavior. The sequence of bifurcations—pitchfork, Hopf, and homoclinic—is independent of the lateral friction and may be described as the unfolding of a singularity that occurs in the frictionless, Hamiltonian limit of the governing equations. Two distinct chaotic regimes are identified: Lorenz chaos at relatively large lateral friction versus Shilnikov chaos at relatively small lateral friction. Both types of homoclinic bifurcations induce chaotic behavior of the recirculation gyres that is dominated by relaxation oscillations with a well-defined period. The relevance of these results to the mid-latitude oceans' observed low-frequency variations is discussed. A previously documented 7-year peak in observed North-Atlantic variability is shown to exist across a hierarchy of models that share the gyre modes and homoclinic bifurcations discussed herein.