A process for the preparation of compounds of formula IA, where R═CH3 (i.e. temozolomide):comprising diazotizing a compound of the formula IIA:where in R is as defined above in the presence of at least one metal halide, an acid and a source of nitrous acid, followed by conversion of acidic solution containing temozolomide. The conversion can be carried out by a liquid-liquid extraction technique in a water immiscible solvent. The temozolomide may be further purified in an acetone-water mixture.