ISLAMABAD — Pakistanis streamed to the polls Saturday, despite a string of attacks that killed 24 people, for a historic vote pitting a former cricket star against a two-time prime minister and an unpopular incumbent.

The violence, which included blasts outside a political office in Karachi that left 10 dead, capped a bloody election season. More than 130 people have been killed in bombings and shootings over the campaign, prompting some to call this one of the deadliest votes in the country’s history.

Despite the bloodshed, many see the election as a key step to solidify civilian rule in a country that has experienced three military coups. It marks the first time in Pakistan’s 65-year history that a civilian government has completed its full term and handed over power in democratic voting. Previous governments have been toppled by military coups or sacked by presidents allied with the army.

With the Pakistani Taliban threatening to target political parties Saturday, an estimated 600,000 security personnel fanned out across the country to protect polling sites and voters. Many Pakistanis seemed determined to cast their ballots despite the violence.

“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 Saturday. “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.”

In a reflection of the enthusiasm surrounding the vote, the secretary of the election commission, Ahmed Khan, told reporters in Islamabad that he expected the turnout to be “massive.”

The election is being watched closely by the United States, which relies on the nuclear-armed country for help fighting Islamic militants and negotiating an end to the war in neighboring Afghanistan.

This vote is notable for more than just the historic handoff of power from one government to another.

The rise of former cricket star Imran Khan has reshaped the Pakistani political scene, challenging the stranglehold of the country’s two main parties and making the outcome of the vote very hard to call.

The 60-year-old Khan is facing off against the Pakistan Muslim League-N, headed by two-time former prime minister Nawaz Sharif and the Pakistan People’s Party, led by President Asif Ali Zardari.

While Sharif has billed himself as the candidate of experience, Khan is trying to tap into the frustrations of millions of Pakistanis who want a change from the politicians who have dominated the nation’s politics for years.

“I never voted for anyone in the past, but today my sons asked me to go to the polling station, and I am here to vote,” said Mohammed Akbar in the northwestern city of Khar. “Imran Khan is promising to bring a good change, and we will support him.”

Khan survived a horrific fall off a forklift during a campaign event Tuesday in the eastern city of Lahore that sent him to the hospital with three broken vertebrae and a broken rib. He is not believed to have voted Saturday because he couldn’t travel to his polling place.

Nobody is sure how effective he will be in translating his widespread popularity into votes, especially considering he boycotted the 2008 election and only got one seat in 2002.

Turnout will be critical, especially among the youth. Almost half of Pakistan’s more than 80 million registered voters are under the age of 35, but young people have often stayed away from the polls in the past.

The election’s outcome is likely riding on the tally in the province of Punjab, Pakistan’s most populous, where Sharif and Khan have been dueling for the people’s support with a series of large rallies and campaign events.

As Sharif cast his ballot at a Lahore polling station, supporters serenaded him with chants of “Lion! Lion!”

“We brought change before. We will bring change again,” he said.

On the campaign trail, Sharif played up his extensive political experience compared to Khan’s, and touted key projects he completed while in office, including a highway between the capital Islamabad and Lahore.

“It’s better to try a lesser evil instead of trying a novice,” said one Lahore voter, Haji Mohammad Younus. “The lesser evils at least have the experience of governing. They might be corrupt but they have lately realized that they have to deliver if they want to survive.”

The mood remained jubilant despite a series of attacks that marred the vote in some districts.

The deadliest violence struck Karachi, where twin blasts blew up outside an office of the Awami National Party, one of three secular liberal parties that have been targeted by Taliban militants during the campaign, said police officer Shabir Hussain. Ten people died in the attack and 30 were wounded.

A roadside bomb in Karachi also killed one person riding in a bus of ANP supporters, and two Pakistani troops were killed when a bomb exploded near a polling station they were guarding.

In the northwestern city of Peshawar a bomb outside a polling station killed one person while two more died when a bomb went off near a police van.

In the southwestern province of Baluchistan, gunmen killed two people outside a polling station in the town of Sorab and a shootout between supporters of two candidates in the town of Chaman killed 6 people, officials said.

There is concern that the violence could benefit Islamist parties and those who take a softer line toward the militants, including Khan and Sharif, because they were able to campaign more freely.

The outgoing Pakistan People’s Party is expected to fare poorly. Voters are fed up with five years of power outages, rising inflation and militant attacks. 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’s appeared at few election events, and was out of the country Saturday.

There were reports that some women in the North Waziristan tribal area were not allowed to vote. Clerics using loudspeakers at local mosques in the cities of Mir Ali and Miran Shah urged women to stay home, and none could be seen at the polls.

Women in Pakistan have had to fight extensive discrimination to assert their electoral rights. They represent only about 43 percent of the roughly 86 million registered voters. In many areas, particularly in the conservative northwest, the men decide ahead of the election that women cannot vote.

Polls were scheduled to close at 5 p.m. local time (1200 GMT and 8 a.m. EST) but the commission extended voting for an extra hour across the country and three hours in parts of Karachi.

The election winner will inherit 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 rising inflation. The country is also battling Islamic 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.

Both Khan and Sharif have favored negotiations with militants in the country’s tribal areas, and Khan has even said he would pull out troops from the borderlands if elected.

That would likely 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 himself to the voting booth — shown live on Pakistani television — instead of mailing in his ballot.