Massive galaxies often are the source of well collimated jets of material that flow outwards for tens to hundreds of kiloparsecs from the regions surrounding the presumed black holes at their centres. The processes by which the jets are formed and collimated have been important problems for many years, and observations have hitherto had insufficient spatial resolution to investigate the length scales associated with these processes. Here we report observations at 43GHz of the inner regions of the nearby active galaxy M87. The data show a remarkably broad jet having an `opening angle' of ~60° near the centre, with strong collimation of the jet occurring at ~30-100 Schwarzschild radii (rS) from the black hole: collimation continues out to ~1,000rS. These results are consistent with the hypothesis that jets are formed by an accretion disk around the central black hole, which is threaded by a magnetic field.