Provided herein is an impurity of varenicline, methylvarenicline, 6-methyl-5,8,14-triazatetracyclo[10.3.1.02,11,04,9]hexadeca-2(11),3,5,7,9-pentaene, and a process for the preparation and isolation thereof. Provided further herein is a highly pure varenicline or a pharmaceutically acceptable salt thereof substantially free of methylvarenicline impurity, processes for the preparation thereof, and pharmaceutical compositions comprising highly pure varenicline or a pharmaceutically acceptable salt thereof substantially free of methylvarenicline impurity.