The forward-backward charge asymmetry for the process $$ q\overline{q}\to Z/{\gamma}^{\ast}\to {\mu}^{+}{\mu}^{-} $$is measured as a function of the invariant mass of the dimuon system. Measurements are performed using proton proton collision data collected with the LHCb detector at $$ \sqrt{s}=7 $$and 8 TeV, corresponding to integrated luminosities of 1 fb1 and 2 fb1 respectively. Within the Standard Model the results constrain the effective electroweak mixing angle to besin2Weff=0.23142±0.00073±0.00052±0.00056,$$ { \sin}^2{\theta}_{\mathrm{W}}^{\mathrm{eff}}=0.23142\pm 0.00073\pm 0.00052\pm 0.00056, $$where the first uncertainty is statistical, the second systematic and the third theoretical. This result is in agreement with the current world average, and is one of the most precise determinations at hadron colliders to date.