Wind forcing of the ocean generates a spectrum of inertia–gravity waves that is sharply peaked near the local inertial (or Coriolis) frequency. The corresponding near-inertial waves (NIWs) are highly energetic and play a significant role in the slow, large-scale dynamics of the ocean. To analyse this role, we develop a new model of the non-dissipative interactions between NIWs and balanced motion. The model is derived using the generalised-Lagrangian-mean (GLM) framework (specifically, the ‘glm’ variant of Soward & Roberts, J. Fluid Mech., vol. 661, 2010, pp. 45–72), taking advantage of the time-scale separation between the two types of motion to average over the short NIW period. We combine Salmon’s (J. Fluid Mech., vol. 719, 2013, pp. 165–182) variational formulation of GLM with Whitham averaging to obtain a system of equations governing the joint evolution of NIWs and mean flow. Assuming that the mean flow is geostrophically balanced reduces this system to a simple model coupling Young & Ben Jelloul’s (J. Mar. Res., vol. 55, 1997, pp. 735–766) equation for NIWs with a modified quasi-geostrophic (QG) equation. In this coupled model, the mean flow affects the NIWs through advection and refraction; conversely, the NIWs affect the mean flow by modifying the potential-vorticity (PV) inversion – the relation between advected PV and advecting mean velocity – through a quadratic wave term, consistent with the GLM results of Bühler & McIntyre (J. Fluid Mech., vol. 354, 1998, pp. 301–343). The coupled model is Hamiltonian and its conservation laws, for wave action and energy in particular, prove illuminating: on their basis, we identify a new interaction mechanism whereby NIWs forced at large scales extract energy from the balanced flow as their horizontal scale is reduced by differential advection and refraction so that their potential energy increases. A rough estimate suggests that this mechanism could provide a significant sink of energy for mesoscale motion and play a part in the global energetics of the ocean. Idealised two-dimensional models are derived and simulated numerically to gain insight into NIW–mean-flow interaction processes. A simulation of a one-dimensional barotropic jet demonstrates how NIWs forced by wind slow down the jet as they propagate into the ocean interior. A simulation assuming plane travelling NIWs in the vertical shows how a vortex dipole is deflected by NIWs, illustrating the irreversible nature of the interactions. In both simulations energy is transferred from the mean flow to the NIWs.