The present invention is based on the discovery of a process for preparing pyrimidin-dione compounds, especially alogliptin and its derivatives, which comprises the reaction of a urea derivative of formula (VIII) with a malonic acid or its derivatives to form intermediates of formulae (VII) or (VII-A), which are subsequently converted to a compound of formula (II) upon introduction of a leaving group X. Compound (II) then reacts with an amine to form compound (I), which is optionally converted to its salts of formula (IV).