The mechanism of a multicomponent reaction between aminoazoles, 1-morpholino-2-nitroalkenes, and benzaldehyde was studied in acidic medium. Performing the reaction in acetic acid led to the formation of 6-nitro-5-phenyl-4,5,6,7-tetrahydropyrazolo[1,5-a]pyrimidines, which subsequently underwent a rearrangement. Reaction conditions were proposed for a multicomponent synthesis with trioxane, and the alkylation reactions of 4,7-dihydroazolo[1,5-a]pyrimidine nitro derivatives were optimized.