It is widely accepted that strong and variable radiation detected over all accessible energy bands in a number of active galaxies arises from a relativistic, Doppler-boosted jet pointing close to our line of sight. The size of the emitting zone and the location of this region relative to the central supermassive black hole are, however, poorly known, with estimates ranging from light-hours to a light-year or more. Here we report the coincidence of a gamma ({gamma})-ray flare with a dramatic change of optical polarization angle. This provides evidence for co-spatiality of optical and {gamma}-ray emission regions and indicates a highly ordered jet magnetic field. The results also require a non-axisymmetric structure of the emission zone, implying a curved trajectory for the emitting material within the jet, with the dissipation region located at a considerable distance from the black hole, at about 10{sup 5} gravitational radii.