The present invention discloses a preparation method of cobimetinib (XL518, GDC-0973) (I). The preparation steps include: taking (2S)-2-piperidinecarboxylic acid as the raw material, performing acyl cyanation, hydrolysis, esterification and Boc protection to obtain an intermediate [2-oxo-2-((2S)-1-tert-butoxycarbonylpiperidin-2-yl)]acetate, performing an addition reaction, a reduction reaction and a cyclization reaction on the intermediate to obtain an intermediate (2S)-1-tert-butoxycarbonyl-2-(3-hydroxyazetidin-3-yl)piperidine, and performing a condensation reaction with a side chain to obtain the cobimetinib (I). The preparation method has the advantages of accessible raw materials, simple technique, high economy and environment friendliness, and is suitable for industrial production.