With only a few exceptions that are well understood, conventional superconductivity does not coexist with long-range magnetic order (for example, ref. 1). Unconventional superconductivity, on the other hand, develops near a phase boundary separating magnetically ordered and magnetically disordered phases2, 3. A maximum in the superconducting transition temperature Tc develops where this boundary extrapolates to zero Kelvin, suggesting that fluctuations associated with this magnetic quantum-critical point are essential for unconventional superconductivity4, 5. Invariably, though, unconventional superconductivity masks the magnetic phase boundary when T < Tc, preventing proof of a magnetic quantum-critical point5. Here we report specific-heat measurements of the pressure-tuned unconventional superconductor CeRhIn5 in which we find a line of quantum–phase transitions induced inside the superconducting state by an applied magnetic field. This quantum-critical line separates a phase of coexisting antiferromagnetism and superconductivity from a purely unconventional superconducting phase, and terminates at a quantum tetracritical point where the magnetic field completely suppresses superconductivity. The T 0 K magnetic field–pressure phase diagram of CeRhIn5 is well described with a theoretical model6, 7 developed to explain field-induced magnetism in the high-Tc copper oxides, but in which a clear delineation of quantum–phase boundaries has not been possible. These experiments establish a common relationship among hidden magnetism, quantum criticality and unconventional superconductivity in copper oxides and heavy-electron systems such as CeRhIn5.