N-Tosyl-2-and-3-acetylpyrrols 1 or N-tosyl-2-pyrrolidone 5 were condensed with cyano compounds in the presence of triflic anhydride (Tf2O) to yield heteroarylpyrimidines. 2, 4- Difunctionalized pyrimidines were obtained by reaction of the corresponding 2, 4-bis (methylsulfonyl) pyrimidines with nucleophiles.