Three exoplanets around the star HR 8799 have recently been discovered by means of differential imaging with large telescopes. Bright scattered starlight limits high-contrast imaging to large angular offsets, currently of the order of ten diffraction beamwidths, 10lambda/D, of the star (where lambda is the wavelength and D is the aperture diameter). Imaging faint planets at smaller angles calls for reducing the starlight and associated photon and speckle noise before detection, while efficiently transmitting nearby planet light. To carry out initial demonstrations of reduced-angle high-contrast coronagraphy, we installed a vortex coronagraph capable of reaching small angles behind a small, well-corrected telescope subaperture that provides low levels of scattered starlight. Here we report the detection of all three HR 8799 planets with the resultant small-aperture (1.5 m) system, for which only 2lambda/D separate the innermost planet from the star, with a final noise level within a factor of two of that given by photon statistics. Similar well-corrected small-angle coronagraphs should thus be able to detect exoplanets located even closer to their host stars with larger ground-based telescopes, and also allow a reduction in the size of potential space telescopes aimed at the imaging of very faint terrestrial planets.