The forward-backward charge asymmetry for the process qq¯¯ →Z/γ ∗ →μ+μ− 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 √s =7 and 8 TeV, corresponding to integrated luminosities of 1 fb−1 and 2 fb−1 respectively. Within the Standard Model the results constrain the effective electroweak mixing angle to be sin2θeffW =0.23142±0.00073±0.00052±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