ISLAMABAD — Despite a bloody campaign marred by Taliban attacks, Pakistan was holding historic elections Saturday pitting a former cricket star against a two-time prime minister once exiled by the army and an incumbent blamed for power blackouts and inflation.

Polls opened Saturday morning across the nation in what is a closely watched race to determine the fate of this nuclear-armed country crucial to stability in the region.

The vote 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 elections. Previous governments have been toppled by military coups or sacked by presidents allied with the powerful army.

Deadly violence struck again Friday, with a pair of bombings against election offices in northwest Pakistan that killed three people and a shooting that killed a candidate in the southern city of Karachi. More than 130 people have been killed in the run-up to the vote, mostly secular party candidates and workers. Most attacks have been traced to Taliban militants, who have vowed to disrupt a democratic process they say runs counter to Islam.

The vote is being watched closely by Washington since the U.S. relies on the country of 180 million people for help in fighting Islamic militants and negotiating an end to the war in neighboring Afghanistan.

The rise of former cricket star Imran Khan, who has almost mythical status in Pakistan, has challenged the dominance of the country's two main political parties, making the outcome of the election very hard to call.

"I think it is the most unpredictable election Pakistan has ever had," said Moeed Yusuf, South Asia adviser at the United States Institute of Peace. "The two-party dominance has broken down, and now you have a real third force challenging these parties."

The election of both the national and provincial assemblies comes at a time of widespread despair in Pakistan, as the country suffers from weak economic growth, rampant electricity and gas shortages, and a deadly Taliban insurgency.

The bombings that killed three people Friday occurred in Miran Shah, the main town in the North Waziristan tribal area, a major sanctuary for the Pakistani Taliban. The blasts also wounded 15 people, said intelligence officials, speaking on condition of anonymity because they were not authorized to talk to the media.

The candidate who was gunned down in Karachi, Shakil Ahmed, was running as an independent for the provincial assembly, said police officer Mirza Ahmed Baig.

There is concern that the violence could benefit Islamist parties and those who take a softer line toward the militants, including Khan and former Prime Minister Nawaz Sharif, because they were able to campaign more freely. The government said it would deploy 600,000 security personnel on election day.

After more than a decade in the political wilderness, the Oxford-educated Khan has emerged as a force in the last two years with the simple message of "change." He has tapped into the frustrations of millions of Pakistanis – especially urban middle class youth – who believe the traditional politicians have been more interested in enriching themselves through corruption than governing.

The two main parties that have dominated politics – the Pakistan People's Party, which led the most recent government, and Sharif's Pakistan Muslim League-N – have ruled the country a total of five times in the past 25 years.

Khan has also struck a chord by criticizing Pakistan's unpopular alliance with the U.S. and controversial American drone attacks against Islamic militants in the country's northwest tribal region.

"I am happy to vote for the person of my choice," said Mohammed Ayub, who was the first man to vote at a polling station in Islamabad. "I am voting for Imran as he is a strong voice against wrongs."

Support for the 60-year-old Khan may have increased out of sympathy following a freak accident this week at a political rally in which he fell 15 feet (4.5 meters) off a forklift, fracturing three vertebrae and a rib. He is expected to make a full recovery and seems to be making the most of the accident. The party has repeatedly aired an interview he did from his hospital bed hours after the fall as a paid advertisement on TV.

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.

Khan faces a stiff challenge from the two main parties, which have spent decades honing vote-getting systems based on feudal ties and political patronage, such as granting supporters government jobs.

Because of the strength of this old-style politics and unhappiness with the outgoing government, many analysts see the Pakistan Muslim League-N as the front-runner in the election. Sharif has twice served as prime minister and is best known for testing Pakistan's first nuclear weapon in 1998.

Sharif 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, known for its pro-business policies, came in second in the 2008 elections and is seen as more religiously conservative than the Pakistan People's Party.

On the campaign trail, Sharif pointed out how much more experience he has than Khan and touted key projects he completed while in office, including a highway between the capital Islamabad and his hometown of Lahore. He's also credited with refraining from attacking the outgoing government and allowing it to finish its full term as a way of strengthening civilian government control.

A poll released this week by a Pakistani political magazine, Herald, showed the two parties led by Sharif and Khan as basically tied, with about 25 percent support each. The Pakistan People's Party was third with about 18 percent. The margin of error was less than three percentage points. But national polls like this do not necessarily reflect election results because seats are granted to whoever gets the most votes per constituency, rather than proportionally across the parties.

Even if the Pakistan Muslim League-N wins the most national assembly seats, many analysts doubt it will have a majority, meaning it would have to cobble together a ruling coalition that could be quite weak.

The performance of the Pakistan Muslim League-N could be heavily influenced by how well Khan's party does.

Both parties appeal to conservative middle class voters in cities in Pakistan's most populous province, Punjab, which will be the main battleground of the election. The province contains over half of the 272 directly elected seats in the national assembly. The Herald poll showed about 39 percent support for Sharif's party in Punjab and close to 31 percent for Khan.

If Khan's party can steal enough votes away from Sharif, it might open the way for the Pakistan People's Party to once again form the government. Despite widespread unhappiness with the party's performance over the past five years, it does have a loyal following in rural areas of southern Sindh province and southern Punjab.

A less likely scenario is that the "political tsunami" Khan has promised does really sweep the country, leaving his party to form the next government.

Given the likelihood of a weak coalition no matter who emerges on top, the new government could have trouble tackling the country' major problems. Two of the most immediate are the electricity crisis, with some parts of the country experiencing blackouts for up to 18 hours a day, and the government's shaky financial situation. The caretaker government is already in discussions with the International Monetary Fund about another unpopular bailout to shore up the country's finances.

The next government will also face the tricky task of managing the relationship with the country's army, which is still considered the strongest institution in Pakistan.

The previous government was able to complete its term largely because the army chief, Gen. Ashfaq Parvez Kayani, held off from directly intervening in politics. However, he is believed to play a dominant role in the background, especially when it comes to foreign policy issues such as the relationship with the U.S. and the country's stance toward the Afghan war. Sharif has a particularly complicated history with the army since he was toppled in a coup.

Given the views of Sharif and Khan, the next government is expected to be more nationalistic and protective of the country's sovereignty when it comes to ties with the U.S. than its predecessor. Sharif likes to recount how he tested Pakistan's first nuclear weapon despite intense U.S. pressure. Khan has been even more critical of Pakistan's alliance with the U.S. and has even threatened to shoot down American drones if he came to power.

But the impact of their views will likely be tempered by the role of the Pakistani army, which values its relationship with the U.S. because of the billions of dollars it has received in military aid.

The army is expected to play a similarly predominant role when it comes to Pakistan's stance toward domestic Taliban militants at war with the state. Both Sharif and Khan have backed negotiations with the Taliban, and Khan has even said he would pull troops out from the tribal region who are battling the militants.

His nickname "Taliban Khan" reflects sentiments among some Pakistanis that he's too soft on the Taliban. Kayani, the army chief, has said the Taliban must accept the country's constitution if it wants peace – something the militants have rejected.

___

Associated Press writers Atif Raza in Karachi and Rasool Dawar in Miran Shah, Pakistan, contributed to this report.

___

Sebastian Abbot can be followed on Twitter at https://twitter.com/sebabbot

Also on HuffPost:

Loading Slideshow...
  • Pakistani Women mourn next to the body of a child, who killed in the Saturday's bombing, during a funeral in Karachi, Pakistan, Sunday, May 5, 2013. Two blasts in Pakistan's southern city of Karachi killed three people on Saturday, May 4, 2013, near the office of a political party critical of the Taliban, heightening tensions ahead of the country's historic May 11 election. (AP Photo/Fareed Khan)

  • Pakistani women mourn their family member, who was killed in a Saturday bombing, during his funeral in Karachi, Pakistan, Sunday, May 5, 2013. Two blasts in Pakistan's southern city of Karachi killed three people on Saturday, May 4, 2013, near the office of a political party critical of the Taliban, heightening tensions ahead of the country's historic May 11 election. (AP Photo/Fareed Khan)

  • Supporters of Pakistan Tehreek-e-Insaaf (PTI) or Movement for Justice party wave party flags as they take part in an election campaign rally in Lahore on May 5, 2013. A roadside bomb exploded at an election rally in southwest Pakistan on Sunday killing two people, officials said as violence continued ahead of historic polls on Saturday. (Arif Ali/AFP/Getty Images)

  • Supporters of former Pakistani Prime Minister Nawaz Sharif wave party flags as they listen to Sharif's addresses during an election campaign meeting in Islamabad on May 5, 2013. (AAMIR QURESHI/AFP/Getty Images)

  • A Pakistani man who was injured in an attack targeting an election office run by the Muttahida Quami Movement, receives treatment at a hospital in Karachi, Pakistan, Tuesday, April 23, 2013. (AP Photo/Shakil Adil)

  • In this Tuesday, April 23, 2013 photo, Pakistani police officers gather at the site of an attack, in Karachi, Pakistan. In the southern city of Karachi, unknown assailants threw a homemade bomb at an election office run by the Muttahida Quami Movement, killing two people and wounding many, police officer Amir Farooqi said. (AP Photo/Fareed Khan)

  • Pakistani police officers and army soldiers, gather at the site of a bomb explosion in Banjot village near Mingora, Pakistan, Sunday, April 14, 2013. Pakistani Taliban attacked two leaders of an anti-militant political party on Sunday in northwest Pakistan, killing one and wounding another in the latest attack targeting members of secular-leaning parties during their campaigns for next month's parliamentary election. (AP Photo/Naveed Ali)

  • Pakistani relatives of a bomb explosion victim, carry his body for burial, in Banjot village near Mingora, Pakistan, Sunday, April 14, 2013. (AP Photo/Naveed Ali)

  • A police officer and army soldiers examine a damaged vehicle at the site of bomb explosion in Banjot village near Mingora, the main town of Pakistan's Swat Valley, Sunday, April 14, 2013. (AP Photo/Sherin Zada)

  • Provincial assembly candidate Masoom Shah, center, who survived a roadside bomb targeting his convoy, rushes to a hospital to receive treatment in Peshawar, Pakistan, Sunday, April 14, 2013. Pakistani Taliban attacked two leaders of an anti-militant political party on Sunday in northwest Pakistan, killing one and wounding another in the latest attack targeting members of secular-leaning parties during their campaigns for next month's parliamentary election. (AP Photo/Mohammad Sajjad)

  • Provincial assembly candidate Masoom Shah, who was injured in a roadside bomb targeting his convoy, is wheeled on a stretcher from the emergency room to another section of a hospital in Peshawar, Pakistan, Sunday, April 14, 2013. (AP Photo/Mohammad Sajjad)

  • Pakistani relatives and volunteers carry the body of a slain election candidate, Saddiq Zaman Khattack, at a hospital mortuary in Karachi on May 3, 2013 following a gunmen attack. A candidate running for parliament in next week's historic Pakistani election was shot dead on Friday along with his three-year-old son after praying in a mosque in Karachi, police said. (ASIF HASSAN/AFP/Getty Images)

  • Relatives and supporters gather in front of the bodies of slain election candidate, Saddiq Zaman Khattack (top) and his younger son, Naseer Khattack 6, at a hospital mortuary in Karachi on May 3, 2013 following a gunmen attack. (ASIF HASSAN/AFP/Getty Images)

  • Pakistani activists of the secular Muttahida Qaumi Movement (MQM) party examine a damaged office after a bomb explosion in Karachi on May 2, 2013. (RIZWAN TABASSUM/AFP/Getty Images)

  • Pakistani activists of the secular Muttahida Qaumi Movement (MQM) party examine a damaged office after a bomb explosion in Karachi on May 2, 2013. (RIZWAN TABASSUM/AFP/Getty Images)

  • Pakistani policemen examine the site of a bomb explosion at the secular Muttahida Qaumi Movement (MQM) party office in Karachi on May 2, 2013. (RIZWAN TABASSUM/AFP/Getty Images)

  • Pakistani men help an injured bomb victim at a hospital following an attack on an election office of a political party in Quetta on May 1, 2013. An election candidate escaped unharmed Wednesday when a suicide bomber blew himself up in southern Pakistan wounding two passers-by, police said, in the latest in a wave of attacks to hit the campaign. (BANARAS KHAN/AFP/Getty Images)

  • A Pakistani cameraman takes footage of the dead body of a slain election candidate Abdul Fateh Magsi on a vehicle outside a hospital in Dera Allayar in Baluchistan province on April 30, 2013. A Pakistani election candidate was shot dead Tuesday in an exchange of fire with security forces at a checkpoint in restive southwestern Baluchistan province, officials said. (STR/AFP/Getty Images)

  • Pakistani volunteers search an election candidates office following a bomb attack in Peshawar on April 28, 2013. Two bomb attacks targeting the offices of election candidates in northwest Pakistan killed at least eight people, officials said, the latest bloodshed ahead of polls next month. (HASHAM AHMED/AFP/Getty Images)

  • A Pakistani man looks at the destroyed office of an election candidate fallowing a bomb attack in the city of Kohat, adjacent to Pakistan's restive tribal areas along the Afghan border on April 28, 2013. (BASIT GILANI/AFP/Getty Images)

  • Pakistani people gather at a political party office a day after bomb attack, in Karachi on April 28, 2013. (ASIF HASSAN/AFP/Getty Images)

  • Pakistani people gather at a political party office a day after bomb attack, in Karachi on April 28, 2013. (ASIF HASSAN/AFP/Getty Images)

  • Pakistani security officials, journalists and local residents gather at the site of a bomb explosion in Karachi on April 27, 2013. (ASIF HASSAN/AFP/Getty Images)