ISLAMABAD, Pakistan — Former Prime Minister Nawaz Sharif began talks on Sunday to form a new government, as partial election returns suggested that he and his party would have a commanding hold on Parliament. But Pakistani election officials said final results would take days, even as outrage grew over accusations of rampant vote-rigging, particularly in Karachi.

Mr. Sharif’s main opponent, Imran Khan, in his first public comments since Saturday’s election, said his party would investigate reports of irregularities. His supporters staged protests in Karachi outside the Election Commission office and in the upscale Clifton neighborhood, demanding a new election for all of that port city’s parliamentary seats. They also demonstrated into the night in Lahore.

“There was rigging in Lahore,” Mr. Khan said in a video message recorded at the hospital in Lahore where he was recovering after a serious fall last week. “What happened in Karachi was witnessed by everyone.”

Mr. Khan’s anticorruption campaign electrified the news media and large crowds in the weeks before the vote. But as returns trickled in over the weekend, it became increasingly apparent that his party would get only about 30 of the 272 seats in Parliament. And even the news of possible consolation prizes — having his party win control of the regional government of Khyber-Pakhtunkhwa Province, and becoming the new opposition leader — was still up in the air, pending further results.