Preliminary voting results in Pakistan showed the party of former cricket star Imran Khan was poised late Wednesday to come into power for the first time, upending the political landscape in the fragile democracy.

Mr. Khan’s Pakistan Tehreek-e-Insaf was performing far better than predicted by pre-election polls, which showed the party marginally in front of that of former Prime Minister Nawaz Sharif.