A battery is a classical apparatus which converts a chemical reaction into a persistent voltage bias able to power electronic circuits. Similarly, a phase battery is a quantum equipment which provides a persistent phase bias to the wave function of a quantum circuit. It represents a key element for quantum technologies based on quantum coherence. Unlike the voltage batteries, a phase battery has not been implemented so far, mainly because of the natural rigidity of the quantum phase that, in typical quantum circuits, is imposed by the parity and time-reversal symmetry constrains. Here we report on the first experimental realization of a phase battery in a hybrid superconducting circuit. It consists of an n-doped InAs nanowire with unpaired-spin surface states and proximitized by Al superconducting leads. We find that the ferromagnetic polarization of the unpaired-spin states is efficiently converted into a persistent phase bias $varphi_0$ across the wire, leading to the anomalous Josephson effect. By applying an external in-plane magnetic field a continuous tuning of $varphi_0$ is achieved. This allows the charging and discharging of the quantum phase battery and reveals the symmetries of the anomalous Josephson effect predicted by our theoretical model. Our results demonstrate how the combined action of spin-orbit coupling and exchange interaction breaks the phase rigidity of the system inducing a strong coupling between charge, spin and superconducting phase. This interplay opens avenues for topological quantum technologies, superconducting circuitry and advanced schemes of circuit quantum electrodynamics.}