The solution provides nitrogen heterocyclic compounds of general formula I, where X is C or N; R 1 is selected from the group of C 1 -C 6 alkyl; Z- is -CH2- or -C(O)-; R 2 is a primary or secondary amine attached via Z to a basic heterocycle selected from the group consisting of anilino; anilino substituted with a di(C 1 -C 6 alkyl)amino group at position 2, 3, or 4; benzylamino; benzylamino substituted with a di(C1-C6 alkyl)amino group in position 2, 3, or 4; 4-phenylpiperidin-1-yl, 1-(C1-C6 alkyl)piperazin-4-yl, 1,2,3,4-tetrahydroisoquinolinyl; 1-(C1-C6 alkanesulfonyl)piperazin-4-yl, 4-[4-(C1-C6 alkyl)-piperazin-1-yl]piperidin-1-yl; and their pharmaceutically acceptable salts with alkali metals, or addition salts with acids. The substances are ATR kinase inhibitors, particularly suitable for treating cancer, both in monotherapy and in combination with other chemotherapeutic agents or radiotherapy.