A simple and efficient synthesis of aryl and heteroaryl substituted pyrimidines has been developed via initial Knoevenagal, subsequent addition and final cyclization of aldehyde, ethylcyanoacetate and guanidine nitrate. Piperidine has been used as a catalyst. Short reaction time, environment friendly procedure and excellent yields are the advantages of this procedure. All synthesized compounds were characterized by IR, NMR and Mass spectral data.