The equations for three-dimensional hydrostatic Boussinesq dynamics are equivalent to a variational principle that is closely analogous to the variational principle for classical electrodynamics. Inertia–gravity waves are analogous to electromagnetic waves, and available potential vorticity (i.e. the amount by which the potential vorticity exceeds the potential vorticity of the rest state) is analogous to electric charge. The Lagrangian can be expressed as the sum of three parts. The first part corresponds to quasi-geostrophic dynamics in the absence of inertia–gravity waves. The second part corresponds to inertia–gravity waves in the absence of quasi-geostrophic flow. The third part represents a coupling between the inertia–gravity waves and quasi-geostrophic motion. This formulation provides the basis for a general theory of inertia–gravity waves interacting with a quasi-geostrophic mean flow.