While Sharif won from Sargodha in Punjab heartland, Khan defeated a strong competitor in Peshawar.
The election, which was affected by terrorist attacks and rigging, is historic for it will mark a smooth transition of power between two democratically elected governments for the first time in the country's 66-year-old history.
Eighty-six million people braved the terrorists' warnings to cast their votes in the election.
The partial count of the votes showed that while Sharif was leading, his party could lose 15 of its seats in the important Punjab province to Khan, who has posed a serious threat to a mainly two-party dominated political system.
Television channels showed the PTI was ahead in more than 50 of the 272 seats in the election. A party has to touch the magic figure of 137 to form the national government.
Khan, the country's best-known sporting icon who led a playboy lifestyle in his playing days, is seen by many as a refreshing change from dynastic politics where reliance on patronage system ensured electoral fortunes.
The PTI has a big appeal to the young and urban voters due to its strong stand against corruption, US drone attack and call for a change in the country's political landscape. About one-third of the country's population is aged below 30.
Khan could deprive the PML(N) of a majority and dash Sharif's hopes to become the prime minister for the third time.
The other major party, PPP, which led the previous ruling coalition, is likely to be placed third in the table, thanks to immense corruption and a discredited leadership.