A one-pot two-stage interaction of acyclic β-ketoesters, dimethylformamide dimethylacetal (DMFDMA) and 2-cyanomethylbenzimidazole was studied. Carried out under microwave irradiation in 2-propanol in the presence of piperidine, this transformation leads to the formation of 4-cyanobenzo [4,5]imidazo [1,2-α]pyridine-2-carboxylates, whereas at room temperature in methanol in the presence of sodium methylate 1-hydroxybenzo [4,5]imidazo[1,2-α]pyridine-4-carbonitriles are formed. Intermediate enamines initially formed from β-ketoesters and DMFDMA attack methylene group of 2-cyanomethylbenzimidazole followed by heterocyclizaton. In the presence of piperidine the benzimidazole nitrogen atom attacks the keto group of the β-ketoester fragment, whereas in the strong basic conditions cyclization occurs by the ester group.