Many unconventional superconductors exhibit a common set of anomalous charge transport properties that characterize them as ‘strange metals’, which provides hope that there is a single theory that describes them1–3. However, model-independent connections between the strange metals and superconductivity have remained elusive. Here, we show that the Hall effect of the unconventional superconductor BaFe2(As1−xPx)2 contains an anomalous contribution arising from the correlations within the strange metal. This term has a distinctive dependence on the magnetic field, which allows us to track its behaviour across the doping–temperature phase diagram, even under the superconducting dome. These measurements demonstrate that the strange metal Hall component emanates from a quantum critical point and, in the zero-temperature limit, decays together with the superconducting critical temperature. This empirically reveals the structure of the connection between superconductivity and quantum criticality, which may be common to the physics of many strange metal superconductors.