ISLAMABAD — Former Pakistani Prime Minister Nawaz Sharif declared victory following a historic election marred by violence Saturday, as unofficial, partial vote counts showed his party with an overwhelming lead.
If his victory is confirmed, it would be a remarkable comeback for the 63-year-old Sharif, who has twice served as the country’s premier but was toppled in a military coup in 1999. He spent years in exile before returning to the country in 2007. His party weathered a strong campaign by former cricket star Imran Khan that energized Pakistan’s young people.
Sharif expressed a desire to work with all parties to solve the country’s problems in a victory speech given to his supporters in the eastern city of Lahore as his lead in the national election became apparent based on unofficial, partial vote counts announced by local Pakistan state TV.
The results indicated Sharif’s party has an overwhelming lead, but would fall short of winning a majority of the 272 directly elected national assembly seats, meaning he would have to put together a ruling coalition.
‘‘I appeal to all to come sit with me at the table so that this nation can get rid of this curse of power cuts, inflation and unemployment,’’ Sharif said.
Despite attacks against candidates, party workers and voters that killed 29 people Saturday, Pakistanis turned out in large numbers to elect the national and provincial assemblies. The high participation was a sign of Pakistanis’ desire for change after years of hardship under the outgoing government, and it offered a sharp rebuke to Taliban militants and others who have tried to derail the election with attacks that have killed more than 150 people in recent weeks.
‘‘Our country is in big trouble,’’ said Mohammad Ali, a shopkeeper who voted in the eastern city of Lahore. ‘‘Our people are jobless. Our business is badly affected. We are dying every day.’’
The vote marked the first time a civilian government has completed its full five-year term and transferred power in democratic elections in a country that has experienced three coups and constant political instability since it was established in 1947.
The election was being watched closely by the United States, which relies on the nuclear-armed country of 180 million people for help fighting Islamic militants and negotiating an end to the war in neighboring Afghanistan.
Passion and energy were seen throughout Pakistan, as millions of people headed to the polls, waving flags and chanting slogans in support of their party. Some were young, first-time voters and others elderly Pakistanis who leaned on canes or friends for support as they dropped their vote in the ballot box.
One man, Bilal Masih, even came to a polling station in the central city of Multan dressed in his wedding attire, saying his bride could wait until he voted. He decorated his wedding car with flowers and a stuffed tiger, the symbol of the Pakistan Muslim League-N party he supports.
‘‘I thought that this was my national duty,’’ said Masih, who was wearing a white and red turban and had garlands of flowers around his neck.
The Pakistani Taliban, which has been waging a bloody insurgency against the government for years, tried to disrupt the election because the militants believe the country’s democracy runs counter to Islam. The government responded by deploying an estimated 600,000 security personnel across the country to protect polling sites and voters.
Many Pakistanis seemed determined to cast their ballots despite a series of gun and bomb attacks against candidates, party workers and voters in cities across the country that killed 29 people Saturday.
‘‘Yes, there are fears. But what should we do?’’ said Ali Khan, who was waiting to vote in the northwestern city of Peshawar, where one of the blasts took place. ‘‘Either we sit in our house and let the terrorism go on, or we come out of our homes, cast our vote, and bring in a government that can solve this problem of terrorism.’’
Many of the attacks in the run-up to the vote targeted secular parties. That raised concern the violence could benefit hard-line Islamists and others who take a softer line toward the militants, like Sharif and Khan, because they were able to campaign more freely.
Many Pakistanis expressed pride that so many of their fellow citizens chose to vote.
‘‘More political activity means more awareness,’’ said Nasira Jibran in Lahore. ‘‘More awareness means more accountability.’’
The apparent victor, Sharif, is best known for testing Pakistan’s first nuclear weapon in 1998, and his party is seen to have a pro-business stance. He was toppled in a military coup by then-army chief Gen. Pervez Musharraf in 1999 and spent years in exile in Saudi Arabia before returning to the country in 2007. His party came in second in the 2008 elections to the Pakistan People’s Party and is seen as more religiously conservative.
Sharif faced a strong challenge from former cricket star Khan’s Pakistan Tehreek-e-Insaf party. The winner of the 1992 cricket World Cup tapped into the frustrations of many Pakistani youths fed up with the country’s traditional politicians.
‘‘It’s now our turn. We youngsters want our say in national affairs,’’ said voter Rubina Riaz in Lahore.
Khan suffered a horrific fall off a forklift during a campaign event Tuesday in Lahore that sent him to the hospital with three broken vertebrae and a broken rib. He didn’t vote Saturday because he couldn’t travel to his polling place.
Sharif countered the challenge from Khan by pointing out how much more experience in government he has and touting key projects he completed while in office, including a highway between the capital Islamabad and his hometown of Lahore.
‘‘It’s all about delivering,’’ said Nayyar Naseem, a voter in Lahore. ‘‘Nawaz Sharif has delivered. He is experienced.’’
The battleground between Sharif and Khan was in Pakistan’s most populous province, Punjab, where both parties appealed to urban middle class voters. The province contains nearly half of the 272 directly-elected seats in the national assembly.
The outgoing Pakistan People’s Party was expected to fare poorly in the election because of unhappiness with its performance leading the last government. The party, which rose to power in 2008 in part by widespread sympathy after the death of party leader Benazir Bhutto, has carried out what many called a lackluster campaign.
Their effort has been hampered by threats of Taliban violence and a lack of high-profile figures to rally the party. Benazir Bhutto’s son, Bilawal Bhutto Zardari, is officially the party chairman and had been expected to play a high-profile role in the election. But he has appeared at few election events, and was out of the country Saturday.
The election commission said it was investigating reports of a lack of polling staff and materials, and threats to election commission staff in some areas of the southern city of Karachi.
The election winner inherits a country struggling on a number of fronts. Pakistanis suffer from rolling blackouts that can be as long as 18 hours a day as well as a stuttering economy. The country is also battling Taliban militants who want to overthrow the government, while on the western border there are fears that a U.S. military departure from Afghanistan will send violence spilling over into Pakistan.
Sharif has favored negotiations with militants in the country’s tribal areas. That could put him at odds with the country’s powerful military. While Pakistan has been under civilian rule for the last five years, the military still is considered the country’s most powerful institution and usually makes the major decisions when it comes to militancy or foreign policy issues such as Afghanistan or India.
In what appeared to be a show of support for democracy in Pakistan, the country’s most powerful military officer, Gen. Ashfaq Parvez Kayani, went to the voting booth himself instead of mailing in his ballot. His gesture was broadcast live of local TV.
Associated Press writers Munir Ahmed and Zarar Khan in Islamabad, Atif Raza in Karachi, Riaz Khan in Peshawar, Rasool Dawar in Mir Ali, Anwarullah Khan in Khar, Abdul Sattar in Quetta, Matiullah Achakzai in Chaman, and Asif Shahzad in Lahore contributed to this report.