Classical novae are the most common astrophysical thermonuclear explosions, occurring on the surfaces of white dwarf stars accreting gas from companions in binary star systems. Novae typically expel about 10−4 solar masses of material at velocities exceeding 1,000 kilometres per second. However, the mechanism of mass ejection in novae is poorly understood, and could be dominated by the impulsive flash of thermonuclear energy, prolonged optically thick winds or binary interaction with the nova envelope. Classical novae are now routinely detected at gigaelectronvolt γ-ray wavelengths, suggesting that relativistic particles are accelerated by strong shocks in the ejecta. Here we report high-resolution radio imaging of the γ-ray-emitting nova V959 Mon. We find that its ejecta were shaped by the motion of the binary system: some gas was expelled rapidly along the poles as a wind from the white dwarf, while denser material drifted out along the equatorial plane, propelled by orbital motion. At the interface between the equatorial and polar regions, we observe synchrotron emission indicative of shocks and relativistic particle acceleration, thereby pinpointing the location of γ-ray production. Binary shaping of the nova ejecta and associated internal shocks are expected to be widespread among novae, explaining why many novae are γ-ray emitters.