Libya's interim rulers Monday elected academic Abdel Rahim al-Kib to head a transitional government as NATO was set to end an air campaign that played a major role in ousting dictator Moamer Kadhafi.
Kib, a native of Tripoli, was elected prime minister in a public vote carried out by the members of the National Transitional Council, an AFP correspondent reported.
The little-known academic who specialises in electrical engineering beat four other candidates, winning 26 out of 51 votes.
"This vote proves that Libyans are able to build their future," NTC chairman Mustafa Abdel Jalil said after he voted.
NATO chief Anders Fogh Rasmussen earlier made a brief visit to Tripoli, saying he foresaw no major role left for the alliance in Libya hours before its air mission was due to officially end.
"At midnight tonight, a successful chapter in NATO's history is coming to an end. But you have also started writing a new chapter in Libya's history," he told a joint press conference with Abdel Jalil.
Rasmussen was whisked off directly for talks at the Rixos Hotel but later had a chance to talk about the country's future with a group of about 60 young Libyans.
The visit came seven months after Western powers fired the first barrage of missiles against Moamer Kadhafi's forces in an air war that played a major role in ousting the veteran dictator.
The no-fly zone and naval blockade, enforced by NATO since March 31, will end Monday at 11:59 pm Libyan time (2159 GMT), as stipulated by a UN Security Council resolution last week that closed the mandate authorising military action.
Operation Unified Protector was terminated even though Abdel Jalil had asked for the alliance to stay until the end of the year, warning that Kadhafi loyalists still posed a threat.
But NATO deemed that civilians were safe from attacks after the new regime declared the country liberated following Kadhafi's death and the fall of his hometown of Sirte on October 20.
Despite having his request for an extension of the mission turned down, the NTC chairman hailed NATO's crucial support and the precision of its air strikes.
"On behalf of the Libyan people, we express our appreciation and gratitude to the alliance, both the NATO alliance and Arab countries and friends. Thank you for that effort, which achieved victory for us," Abdel Jalil said.
"The NATO operation in Libya was successful in a great way... It was very accurate in the way that civilians were not affected. I think the people of Tripoli testify to that," he added.
Signup to our newsletter and follow us on Facebook and Twitter!
Earlier, in an exclusive interview with AFP, Rasmussen said the military alliance was ready to help the new Libya.
"We have... clearly stated that if the new political leadership in Libya so requests, NATO stands ready to help them in their transformation to a democracy," he said.
Areas where NATO could help included defence and security reform, he said, adding that member countries might be able to assist with border control.
"(But with) no NATO troops on the ground, I don't foresee a major NATO role. It's now for the United Nations to take the lead of the international assistance to the new authorities in Libya," the NATO secretary general told AFP.
His trip came three days after NATO allies confirmed a decision to end the mission, declaring that the 28-nation alliance had fulfilled its UN mandate to protect civilians from a brutal repression.
Western strikes helped tip the balance of power in Libya's conflict, preventing him from crushing a revolt that erupted in mid-February.
The bombing raids stopped Kadhafi forces from marching into the rebel eastern city of Benghazi in February and pulverised the strongman's air force.
The conflict then appeared headed into a stalemate as the ill-trained rebel forces struggled to fight their way west towards Tripoli. But with NATO destroying thousands of military targets, the NTC eventually took the capital in August, sending Kadhafi into hiding.
While NATO has steadfastly denied targeting Kadhafi during the campaign, it was an alliance air strike that hit his convoy as it fled Sirte, leading to his capture and killing.
Rasmussen insisted NATO did not know Kadhafi was in the convoy.
"No, we didn't know. Kadhafi was not a target of our operations. We hit legitimate military targets and an armed convoy is a legitimate military target because it can constitute a threat to civilians," he told AFP on Monday.
A coalition led by the United States, France and Britain launched the first salvos in the air war on March 19, before handing over command of the mission to NATO at the end of March.
The alliance, joined by Arab partners Qatar and United Arab Emirates, flew some 26,000 sorties and hit almost 6,000 targets during the conflict.
Rasmussen said NATO had no confirmed civilian casualties caused by its operations.
"On one occasion we publicly declared that we could not exclude the possibility that we might have caused civilian casualties but the follow up investigation couldn't confirm that," he said.