Earth and its magnetosphere are immersed in the supersonic flow of the solar-wind plasma that fills interplanetary space. As the solar wind slows and deflects to flow around Earth, or any other obstacle, a 'bow shock' forms within the flow. Under almost all solar-wind conditions, planetary bow shocks such as Earth's are collisionless, supercritical shocks, meaning that they reflect and accelerate a fraction of the incident solar-wind ions as an energy dissipation mechanism1,2, which results in the formation of a region called the ion foreshock3. In the foreshock, large-scale, transient phenomena can develop, such as 'hot flow anomalies'4-9, which are concentrations of shock-reflected, suprathermal ions that are channelled and accumulated along certain structures in the upstream magnetic field. Hot flow anomalies evolve explosively, often resulting in the formation of new shocks along their upstream edges5,10, and potentially contribute to particle acceleration11-13, but there have hitherto been no observations to constrain this acceleration or to confirm the underlying mechanism. Here we report observations of a hot flow anomaly accelerating solar-wind ions from roughly 1-10 kiloelectronvolts up to almost 1,000 kiloelectronvolts. The acceleration mechanism depends on the mass and charge state of the ions and is consistent with first-order Fermi acceleration14,15. The acceleration that we observe results from only the interaction of Earth's bow shock with the solar wind, but produces a much, much larger number of energetic particles compared to what would typically be produced in the foreshock from acceleration at the bow shock. Such autogenous and efficient acceleration at quasi-parallel bow shocks (the normal direction of which are within about 45 degrees of the interplanetary magnetic field direction) provides a potential solution to Fermi's 'injection problem', which requires an as-yet-unexplained seed population of energetic particles, and implies that foreshock transients may be important in the generation of cosmic rays at astrophysical shocks throughout the cosmos.