The Solar system's Oort cloud can be perturbed by the Galactic tide and by individual passing stars. These perturbations can inject Oort cloud objects into the inner parts of the Solar system, where they may be observed as the long-period comets (periods longer than 200 yr). Using dynamical simulations of the Oort cloud under the perturbing effects of the tide and 61 known stellar encounters, we investigate the link between long-period comets and encounters. We find that past encounters were responsible for injecting at least 5 per cent of the currently known long-period comets. This is a lower limit due to the incompleteness of known encounters. Although the Galactic tide seems to play the dominant role in producing the observed long-period comets, the non-uniform longitude distribution of the cometary perihelia suggests the existence of strong – but as yet unidentified – stellar encounters or other impulses. The strongest individual future and past encounters are probably HIP 89825 (Gliese 710) and HIP 14473, which contribute at most 8 and 6 per cent to the total flux of long-period comets, respectively. Our results show that the strength of an encounter can be approximated well by a simple proxy, which will be convenient for quickly identifying significant encounters in large data sets. Our analysis also indicates a smaller population of the Oort cloud than is usually assumed, which would bring the mass of the solar nebula into line with planet formation theories.