Imran Khan, Pakistan’s former prime minister, has spent the duration of the country’s electoral campaign in jail, disqualified from running in what experts have described as one of the least credible general elections in the country’s 76-year history.

But from behind bars, he has been rallying his supporters in recent months with speeches that use artificial intelligence to replicate his voice, part of a tech-savvy strategy his party deployed to circumvent a crackdown by the military.

And on Saturday, as official counts showed candidates aligned with his party, Pakistan Tehreek-e-Insaf, or P.T.I., winning the most seats in a surprise result that threw the country’s political system into chaos, it was Mr. Khan’s A.I. voice that declared victory.

“I had full confidence that you would all come out to vote. You fulfilled my faith in you, and your massive turnout has stunned everybody,” the mellow, slightly robotic voice said in the minute-long video, which used historical images and footage of Mr. Khan and bore a disclaimer about its A.I. origins. The speech rejected the victory claim of Mr. Khan’s rival, Nawaz Sharif, and urged supporters to defend the win.

As concerns grow about the use of artificial intelligence and its power to mislead, particularly in elections, Mr. Khan’s videos offer an example of how A.I. can work to circumvent suppression. But, experts say, they also increase fear about its potential dangers.