The binary neutron star merger GW170817 was accompanied by radiation across the electromagnetic spectrum and localized to the galaxy NGC 4993 at a distance of 41+/-3 Mpc. The radio and X-ray afterglows of GW170817 exhibited delayed onset, a gradual rise in the emission with time as t^0.8, a peak at about 150 days post-merger, followed by a relatively rapid decline. To date, various models have been proposed to explain the afterglow emission, including a choked-jet cocoon and a successful-jet cocoon (a.k.a. structured jet). However, the observational data have remained inconclusive as to whether GW170817 launched a successful relativistic jet. Here we show, through Very Long Baseline Interferometry, that the compact radio source associated with GW170817 exhibits superluminal motion between two epochs at 75 and 230 days post-merger. This measurement breaks the degeneracy between the models and indicates that, while the early-time radio emission was powered by a wider-angle outflow (cocoon), the late-time emission was most likely dominated by an energetic and narrowly-collimated jet, with an opening angle of <5 degrees, and observed from a viewing angle of about 20 degrees. The imaging of a collimated relativistic outflow emerging from GW170817 adds substantial weight to the growing evidence linking binary neutron star mergers and short gamma-ray bursts.