A measurement of the forward-backward asymmetry [Formula: see text] of oppositely charged lepton pairs ([Formula: see text] and [Formula: see text]) produced via [Formula: see text] boson exchange in pp collisions at [Formula: see text] [Formula: see text] is presented. The data sample corresponds to an integrated luminosity of 19.7[Formula: see text] collected with the CMS detector at the LHC. The measurement of [Formula: see text] is performed for dilepton masses between 40[Formula: see text] and 2[Formula: see text] and for dilepton rapidity up to 5. The [Formula: see text] measurements as a function of dilepton mass and rapidity are compared with the standard model predictions.