The reaction has two stages: nucleophilic addition of H2N–Z (here Z = –NHAr) to C=O, then acid-assisted loss of water from the addition product to form C=N.

(a) pH ≈ 1: the reagent is a base. In strong acid nearly all of it is protonated on the terminal nitrogen:
H2N–NHAr+H+⇌H3N+–NHAr
The protonated nitrogen has no lone pair, so it cannot attack the carbonyl carbon. With almost no free nucleophile left, the first stage stops, even though the carbonyl is well activated.
(b) pH ≈ 10: there is almost no H+.
- Addition is slower because the carbonyl oxygen is not protonated, so the carbonyl carbon is less electrophilic.
- Dehydration is very slow because the –OH of the addition product must be protonated to –OH2+ before it can leave as water. OH− is a poor leaving group.
At pH 4–5 there is enough acid to activate the carbonyl and to protonate the –OH for dehydration, while most of the hydrazine is still unprotonated and free to act as a nucleophile. The rate is highest when both needs are met together.
