Provided herein is an impurity of varenicline, 6-methyl-5,8,14-triazatetracyclo[l 0.3.1.02n,049]hexadeca-2(l l),3,5,7,9-pentaene (methylvarenicline) impurity, 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, a process for the preparation thereof, and pharmaceutical compositions comprising highly pure varenicline or a pharmaceutically acceptable salt thereof substantially free of methylvarenicline impurity.