ISLAMABAD — Pakistani lawmakers elected a textile businessman who briefly served as the governor of southern Sindh province as the country's next president Tuesday, the election commission chief said, a result that was widely expected.

The election of Mamnoon Hussain, nominated by the ruling Pakistan Muslim League-N party, followed a late night attack by 150 Taliban militants on a prison, illustrating one of the major challenges facing the new president. The fighters freed more than 250 prisoners, including 38 suspected militants, and killed 14 people, including guards and Shiite Muslim prisoners, officials said.

Pakistan's largely ceremonial president is not elected by popular vote, but by lawmakers in the Senate, National Assembly and the assemblies of the four provinces. Tuesday's outcome was widely predicted because the PML-N won majorities in the National Assembly and the assembly of Pakistan's most populous province, Punjab, in June, all but assuring that Hussain would win.

Hussain received 432 votes from lawmakers on Tuesday, said the head of Pakistan's election commission, Fakhruddin Ibrahim. The only other candidate, retired judge Wajihuddin Ahmed, received 77 votes. Ahmed was nominated by Pakistan Tehreek-e-Insaf, a party led by former cricket star Imran Khan.

Prime Minister Nawaz Sharif will remain the most powerful figure in the civilian government in Pakistan, a key ally for the United States in battling Islamic militants and negotiating an end to the war in neighboring Afghanistan.

The vote was marred by controversy because of the Supreme Court's decision to accept a request by the ruling party to move the election forward. It was originally scheduled for Aug. 6. The request came because some lawmakers wanted to make a pilgrimage to Saudi Arabia toward the end of the Islamic holy month of Ramadan, which ends around Aug. 8.

The country's former ruling party, the Pakistan People's Party, which has the second highest number of seats in the National Assembly, announced it would boycott the presidential election over the court's ruling. The PPP complained that the judges ruled without hearing from the opposition, and the new election date didn't give the party enough time to campaign.

The court's decision sparked criticism outside the party from observers who have long warned about the Supreme Court's tendency to overreach. They argued that the decision about the election date should have been left to the country's election commission.

Hussain was born to an industrialist family in 1940 in the Indian city of Agra. His family settled in Karachi, the capital of Sindh province, after Pakistan was carved out of British India in 1947, and set up a textile business there.

Hussain is a longtime member of the PML-N and served as governor of Sindh for about four months in 1999, but otherwise has not been a prominent figure in national politics.

Hussain will replace the current president, Asif Ali Zardari, whose five-year term ends on Sept. 8. Zardari rose to power after his wife, former Prime Minister Benazir Bhutto, was killed in a gun and bomb attack in December 2007.

Zardari has been a contentious figure as president and has often battled with both the powerful army and the Supreme Court.

His biggest accomplishment is widely seen as guiding Pakistan's first civilian government to finish its full five-year term and transferring power in democratic elections in a country plagued by military coups. He also agreed to a constitutional amendment that transferred many of the president's powers to the prime minister, leaving his position as largely ceremonial.

But Zardari's government is widely perceived to have done little to address the major problems facing the country, especially the pervasive electricity shortages that crippled Pakistan's economy and left some people without power for up to 20 hours per day.

"Zardari will be remembered as a quite a controversial president, but a major survivor," said Pakistani analyst Hasan Askari Rizvi.

The army launched major operations against the Pakistani Taliban during Zardari's tenure, but the group has proved resilient and continues to stage frequent attacks against security personnel and civilians.

The attack on the prison late Monday night was in the town of Dera Ismail Khan, near Pakistan's semiautonomous tribal region, the main sanctuary for Taliban and al-Qaida militants.

The militants killed six policemen, six Shiite Muslim prisoners and two civilians, said Dera Ismail Khan's commissioner, Mushtaq Jadoon. One of the Shiites was beheaded. Many hard-line Pakistani militants consider the country's minority Shiites to be heretics.

The jail attack began around 11:30 p.m. on Monday night, when 150 militants detonated dozens of bombs to collapse the prison's walls and then streamed inside. Some were disguised as policemen, said intelligence officials, speaking on condition of anonymity because they were not authorized to talk to reporters.

The militants, who chanted "God is great" and "Long live the Taliban," fired rocket-propelled grenades and lobbed hand grenades during the attack.

The attackers used megaphones to call out the names of specific prisoners. They broke open cells and freed 253 prisoners, including 25 "dangerous terrorists," said Jadoon.

The chief justice of surrounding Khyber Pakhtunkhwa province, Pervaiz Khattak, said 38 of the escaped prisoners were either convicted or on trial on terrorism charges.

The militants ended the raid around 4 a.m. Authorities declared a curfew and were searching for the militants and the escaped prisoners.

____

Associated Press writers Zarar Khan in Islamabad, Ishtiaq Mahsud in Dera Ismail Khan and Rasool Dawar in Peshawar contributed to this report.