Context : Aims : We aim at investigating with high angular resolution the NH _ { 3 } /N _ { 2 } H ^ { + } abundance ratio toward the high-mass star-forming region AFGL 5142 in order to study whether the NH _ { 3 } /N _ { 2 } H ^ { + } ratio behaves similarly to the low-mass case , for which the ratio decreases from starless cores to cores associated with young stellar objects ( YSOs ) . Methods : CARMA was used to observe the 3.2 mm continuum and N _ { 2 } H ^ { + } ( 1–0 ) emission toward AFGL 5142 . We used NH _ { 3 } ( 1,1 ) and ( 2,2 ) , as well as HCO ^ { + } ( 1–0 ) and H ^ { 13 } CO ^ { + } ( 1–0 ) data available from the literature to study the chemical environment . Additionally we performed a time-dependent chemical modeling of the region . Results : The 3.2 mm continuum emission reveals a dust condensation of \sim 23 M _ { \sun } associated with the massive YSOs , deeply embedded in the strongest NH _ { 3 } core ( hereafter central core ) . The dense gas emission traced by N _ { 2 } H ^ { + } reveals two main cores , the western core of \sim 0.08 pc in size and the eastern core of \sim 0.09 pc , surrounded by a more extended and complex structure of \sim 0.5 pc , mimicking the morphology of the NH _ { 3 } emission . The two cores are located to the west and to the east of the 3.2 mm dust condensation . Toward the central core the N _ { 2 } H ^ { + } emission drops significantly , indicating a clear chemical differentiation in the region . The N _ { 2 } H ^ { + } column density in the central core is one order of magnitude lower than in the western and eastern cores . Furthermore , we found low values of the NH _ { 3 } /N _ { 2 } H ^ { + } abundance ratio \sim 50–100 toward the western and eastern cores , and high values up to 1000 associated with the central core . The chemical model used to explain the differences seen in the NH _ { 3 } /N _ { 2 } H ^ { + } ratio indicates that density , and in particular temperature , are key parameters in determining the abundances of both NH _ { 3 } and N _ { 2 } H ^ { + } . The high density ( n \simeq 10 ^ { 6 } cm ^ { -3 } ) and temperature ( T \simeq 70 K ) reached in the central core allow molecules such as CO to evaporate from grain mantles . The CO desorption causes a significant destruction of N _ { 2 } H ^ { + } , which favors the formation of HCO ^ { + } . This result is supported by our observations , which show that N _ { 2 } H ^ { + } and HCO ^ { + } are anticorrelated in the central core . The observed values of the NH _ { 3 } /N _ { 2 } H ^ { + } ratio in the central core can be reproduced by our model for times t \simeq 4.5 - 5.3 \times 10 ^ { 5 } yr while in the western and eastern cores the NH _ { 3 } /N _ { 2 } H ^ { + } ratio can be reproduced by our model for times in the range 10 ^ { 4 } -3 \times 10 ^ { 6 } yr . Conclusions : The NH _ { 3 } /N _ { 2 } H ^ { + } abundance ratio in AFGL 5142 does not follow the same trend as in regions of low-mass star formation mainly due to the high temperature reached in hot cores .