The P2 experiment aims at high-precision measurements of the parity-violating asymmetry in elastic electron-proton and electron-$^{12}$C scatterings with longitudinally polarized electrons. We discuss here the sensitivity of P2 to new physics mediated by an additional neutral gauge boson $Z$ of a new $U(1)$ gauge symmetry. If the charge assignment of the $U(1)$ is chiral, i.e., left- and right-handed fermions have different charges under $U(1)$, additional parity-violation is induced directly. On the other hand, if the $U(1)$ has a non-chiral charge assignment, additional parity-violation can be induced via mass or kinetic $Z$-$Z$ mixing. By comparing the P2 sensitivity to existing constraints, we show that in both cases P2 has discovery potential over a wide range of $Z$ mass. In particular, for chiral models, the P2 experiment can probe gauge couplings at the order of $10^{-5}$ when the $Z$ boson is light, and heavy $Z$ bosons up to 79 (90) TeV in the proton ($^{12}$C) mode. For non-chiral models with mass mixing, the P2 experiment is sensitive to mass mixing angles smaller than roughly $10^{-4}$, depending on model details and gauge coupling magnitude.