Steady three-dimensional flows in lid-driven cavities are investigated numerically using a high-order spectral-element solver for the incompressible Navier–Stokes equations. The focus is placed on critical points in the flow field, critical limit cycles, their heteroclinic connections, and on the existence, shape, and dependence on the Reynolds number of Kolmogorov–Arnold–Moser (KAM) tori. In finite-length cuboidal cavities at small Reynolds numbers, a thin layer of chaotic streamlines covers all walls. As the Reynolds number is increased, the chaotic layer widens and the complementary KAM tori shrink, eventually undergoing resonances, until they vanish. Accurate data for the location of closed streamlines and of KAM tori are provided, both of which reach very close to the moving lid. For steady periodic Taylor–Görtler vortices in spanwise infinitely extended cavities with a square cross section, chaotic streamlines occupy a large part of the flow domain immediately after the onset of Taylor–Görtler vortices. As the Reynolds number increases, the remaining KAM tori vanish from the Taylor–Görtler vortices, while KAM tori grow in the central region further away from the solid walls.