TRIPOLI—Libya’s leaders on Monday elected a U.S.-educated engineering professor to serve as prime minister during the critical postwar period, in which the country will try to create an army out of hundreds of ragtag militias and launch its first democratic elections.

Abdurraheem el-Keib, a dual U.S.-Libyan citizen, was chosen by members of the Transitional National Council who deposited ballots into a transparent box. The televised session was a stark sign of the change from the 42-year dictatorship of Moammar Gaddafi.

Libya has been in political limbo in recent weeks as the eight-month war ground to a close and the political leadership prepared to hand over the reins to a new peacetime government. El-Keib is expected to announce a Cabinet in the next few days.

The problems that will face him are immense, ranging from collecting tens of thousands of weapons now in the hands of militias, to jump-starting the economy.

“He is up to the challenge,” Abdurrazag al-Aradi, a member of the council, said on Libyan television. El-Keib is expected to serve until elections in June for a body to oversee the writing of a new constitution

El-Keib, a resident of Tripoli, earned his PhD at North Carolina State University in 1984 and was a longtime professor at the University of Alabama. He joined the interim council last spring.

Colleagues said he was a technocrat who appealed to a variety of factions and was considered intelligent and charismatic. “He’s not from any ideological faction. He’s just a nationalist,” said Abdurrazag Mukhtar, a council member for Tripoli.

He replaces Mahmoud Jibril, an American-educated political scientist who was seen as divisive and criticized for frequent overseas travel. Jibril did not seek re-election.

El-Keib’s election came just hours before NATO formally ended its seven-month bombing campaign in Libya.

“You acted to change your history and your destiny. We acted to protect you. Together we succeeded,” NATO Secretary-General Anders Fogh Rasmussen told interim President Mustafa Abdel Jalil at a news conference.

Libya’s transitional government had asked the alliance to extend its operations until the end of the year, to ensure security in the postwar period. But NATO officials said the north African nation could ask for bilateral help from allies on such things as border security. Rasmussen said individual allies would continue to enforce a U.N. weapons embargo.

More than 8,000 servicemen and women from the United States and other countries participated in the NATO operation to enforce a no-fly zone over Libya and prevent Gaddafi’s forces from massacring civilians, Rasmussen said. Allied air forces struck nearly 6,000 targets, playing a key role in cutting the supply lines to Gaddafi troops.

Libya’s revolutionaries declared the country liberated just over a week ago, after the fall of Gaddafi’s hometown, Sirte, and his capture and death.

Interim President Mustafa Abdel Jalil thanked NATO for its support. “On behalf of the Libyan people, we express our appreciation and gratitude,” he said.

Abdel Jalil also said international experts were expected to arrive in Libya this week to examine two sites where the revolutionary government has found suspected chemical weapons hidden by the Gaddafi government.

Abdel Jalil declined to say where the sites were located. Another official of the transitional government, Shamsiddin Ben Ali, said that one of them was near the southern desert city of Sabha.

Libya pledged to destroy its chemical weapons and abandon its quest for nuclear arms in a 2004 rapprochement with the West. At the time, it declared it had about 25 metric tons of a blistering agent, sulfur mustard, and over 3,500 bombs to carry chemical weapons. Those were in the process of being destroyed when the uprising occurred.

Michael Luhan, a spokesman for the Organization for the Prohibition of Chemical Weapons, said Monday that it was sending a team to check out the reports.

“We simply cannot comment on the validity of these claims” until inspectors have a chance to examine the material that was found, he said. He noted that during the war there were several reports of chemical weapons that turned out to be false.

Rasmussen was asked whether NATO might consider intervening in nearby Syria, where demonstrators have also risen up against an autocratic government. “We have no intention whatsoever to intervene in Syria,” said Rasmussen. “I can completely rule that out.”