A mechanism for the reaction of diformylhydrazine with o- and p-aminophenols has been studied by quantum-chemical calculations within the framework of electron density functional theory using the B3LYP/6-311++G (d,p)//B2PLYP/6-311++G (d, p) basis sets. It is shown that the first stage of this reaction involves nucleophilic addition of the aminophenol nitrogen to one of the carbonyl groups of diformylhydrazine to afford an unstable geminal amino alcohol, which can be further dehydrated to iminohydrazide or hydrazonamide. The prototropic imino-amine rearrangement occurring in the iminohydrazide delivers hydrazonamide, The latter, owing to nucleophilic attack of the nitrogen atom at the second carbonyl group, is converted into a cyclic amino alcohol, dehydration of which produces the target 1,2,4-triazole. The obtained results have been compared with the data NMR spectroscopy.