Treatment of enaminone derivative 6-(3-dimethylamino-acryloyl)-5-(1-pyrrolyl)-4-methyl-2-phenylthieno[2,3-d]pyrimidine 1 with appropriate hydrazine compounds 2a,b in refluxing ethanol afforded the corresponding 6-(1-substituted-pyrazol-5-yl)-2-phenylthieno[2,3-d]pyrimidines 3a,b. Cyclization of enaminone derivative 1 with appropriate guanidine compounds 13a-c in the presence of a basic catalyst yields the corresponding 6-(2-substituted-pyrmidin-6-yl)-2-phenylthieno[2,3-d]pyrimidines 15a-c. The compound 15c can be cyclized with appropriate a-halogenocarbonyl compounds 16a-d to afford the corresponding 6-(2-substituted-imidazo[1,2-a]pyrimidin-7-yl)-2-phenylthieno[2,3-d]pyrimidines 17a-d. On the other hand, the pyrazolo[1,5-a]pyrimidines 20a-c, pyrido(pyrimido)[2,3:4,3]pyrazolo[1,5-a]pyrimidines 22a-c, pyrido[4,5:4,3]pyrazolo[1,5-a]pyrimidine 24, 1,2,4-triazolo[1,5-a]pyrimidine 26a, and 1,2,3,4-tetrazolo[1,5-a]pyrimidine derivative 26b were also obtained by the intramolecular cyclization of enaminone derivative 1 with appropriate 5(3)-amino-pyrazole derivatives 18a-c, 21a-c, 23, 3-amino-1,2,4-triazole 25a and 5-amino-1H-tetrazole 25b under acid conditions, respectively.