2-Aminopyrimidines of the formula I ##STR1## in which X and Y are O or S and R.sup.1 and R.sup.2 independently of one another are lower alkyl, alkoxyalkyl or haloalkyl, are obtained by reacting propanediimidates of the formula II R.sup.1 --X--C(.dbd.NH)--CH.sub.2 --C(.dbd.NH)--Y--R.sup.2 (II) or salts thereof with cyanamide in the presence of a base at pH values above pH 7. The process allows the aminopyrimidines to be prepared in a one-pot reaction