On treatment of 3-amino-5-aryl-1H-pyrazoles 1 with dialkyl dicyanofumarates (=(E)-but-2-enedioates) 4 in boiling 1,2-dichloroethane, two competitive reactions occurred leading to 3-aryl-5-cyano-6,7-dihydro-6-oxo-1H-pyrazolo [3,4-b]pyridine-4-carboxylates 10 and 7-amino-2-arylpyrazolo[1,5-a]pyrimidine-5,6-dicarboxylates 11. In DMF at room temperature, as well as at 100°, only compounds 10 were isolated. The formation of the major products of type 10 was rationalized via Michael addition of 1 as a C(4)-nucleophile onto 4, followed by HCN elimination and lactamization. On the other hand, the minor products 11 result from a Michael addition of 1 onto 4 via the NH2 group, and subsequent HCN elimination and cyclization. The structures of the products have been established by X-ray crystallography.