Fourteen years after he was overthrown and exiled by a military dictator, the former Pakistani prime minister known to his supporters as "the Lion" claimed victory on Saturday night in one of most dramatic general elections in the country's history.

Nawaz Sharif, of the Pakistan Muslim League-Nawaz party (PML-N), was set to become the next prime minister of the troubled country as it grapples with crises on multiple fronts after it became clear he had secured a commanding lead despite the challenge from Imran Khan, the former cricketer who waged a groundbreaking campaign credited with galvanising an army of youthful new voters.

Although final verified results were still hours away, the country's television networks projected Sharif heading for an ultimate tally of around 110 seats that should give him the parliamentary majority he said was needed to fix Pakistan's ailing economy.

Khan's Pakistan Tehreek-e-Insaf (PTI) appeared to be headed for a final vote tally of around 35 seats, in line with the expectations of many analysts but far below the stratospheric expectations of his followers who had been repeatedly promised a "tsunami" that would sweep away the country's established parties.

Compounding the PTI's humiliation, Khan lost one of the seats he was personally contesting in Lahore. Although Khan won other seats, victory in the capital of rich and populous Punjab province was seen as vital if the PTI was to sweep all before him.

It was clear throughout the day that Khan was struggling against his PML-N opponent, Sardar Ayaz Sadiq, an old friend from Khan's schooldays at Lahore's elite Aitchison College.

Sadiq enjoyed solid support from his personal biradari – the traditional clan networks that Khan has urged voters to ignore when they cast their votes.

"I will vote for Sadiq because we have respect for our elders," said Usman Jamil, a 23-year-old office worker. "This system is very strong in Pakistan and we must respect it."

Meanwhile the Pakistan Peoples party (PPP), which is wildly unpopular after five tumultuous years in government, was battered at the polls. It was set to secure around 35 seats, most of them in its traditional rural strongholds in Sindh province.

Sharif emerged onto the balcony of the PML-N headquarters in Lahore well before midnight to address supporters who cheered and waved the green flags of the party.

He said he was prepared to work with all other parties to try to fix the country's many problems.

"We want to change the destiny of the country and fulfil the promises we made to the nation during the election campaign," he said.

While PML-N supporters erupted in noisy celebration across Lahore, PTI backers reacted sullenly to their disappointing result. Some were seen beating cricket bats – the symbol of the party – on one of the city's main boulevards.

One gain for Khan was in Khyber Pakhtunkhwa, where the PTI won enough seats to make it a leading partner in a coalition government.

However, given the province's acute problems and struggle with Taliban militancy, it may prove a poisoned chalice for a party that has never come close to governing anything in its short history.

The election was the first time in the country's history that one elected government has handed power to another.

The day was also marred by violence that killed 22 people and rampant vote rigging in the country's biggest city. Politicians began crying foul even before counting began in the 70,000 polling stations throughout the country.

The PTI in particular complained of blatant efforts to intimidate voters in Defence and Clifton, two affluent neighbourhoods in Karachi where Khan has a devoted following.

Sana Bilal, a 28-year-old PTI supporter, said her polling station located in a school in the upscale Defence neighbourhood never even opened.

"There were people who have been waiting outside since 8am [the official start of polling nationwide]," she said. "It was a sea of PTI supporters."

"Everyone is just really angry that we've been deprived of our right to vote."

The Muttahida Qaumi Movement (MQM), the dominant political party in the city, was blamed for attempting to suppress voting in in a bid to prevent the PTI eating into their territory.