S-Alkyl and S-aryl thioesters react with nitriles in the presence of triflic anhydride to form substituted 4-alkylthio- and 4-arylthiopyrimidines. However, when methyl thiocyanate is used as nitrile, dithioimidocarbonates are formed. A mechanism to explain these differences is postulated.