The present invention provides an improved process for preparing an aminopyrimidine derivative or pharmaceutically acceptable salt thereof having a selective inhibitory activity against protein kinases, especially against the protein kinases for mutant epidermal growth factor receptors. And also, the present invention provides novel intermediates useful for said process and processes for preparing the same.