A method for the preparation of 1-(N-ribofuranosyl)-6-imino-1,6-dihydropyrimidin-4-amines 3 or 4-(N-ribofuranosyl)-6-aminopyrimidines 4 via glycosylation of 4-aminopyrimidines 2 or 5 is described. Silylated 4-aminopyrimidines 2 or 5 upon ribosylation with 1 provide products 3. When intermediates 3 contain a strongly electron-withdrawing group, such as C(4)-Cl or C(5)-NO2, they rearrange to products 4 in the presence of aqueous ammonia. A mechanism is proposed that involves a ring-opening/ring-closing (Dimroth) rearrangement.