A broad range of differently substituted dihydropyrimidines and thiazines can be efficiently prepared by using a four-component reaction between phosphonates, nitriles, aldehydes, and iso(thio)cyanates. The scope and limitations of this multicomponent reaction are fully described. Variation of all four components has been investigated. The nitrile and aldehyde inputs can be varied extensively, but variation of the phosphonate input remains limited. An interesting rearrangement leading to phosphoramidates has been observed. Furthermore, the multicomponent reaction seems to be restricted to the use of isocyanates with strongly electron-withdrawing substituents, but an interesting additional exchange reaction under microwave conditions leads to dihydropyrimidines with less electron-withdrawing substituents at N3. In addition, a diastereoselective formation of dihydropyrimidines has been observed when using a chiral aldehyde as the input. Finally, by changing the isocyanate component to an isothiocyanate, thiazines are efficiently formed instead of the corresponding thio-dihydropyrimidines.