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 today at local time 11:59 pm, as stipulated by a UN Security Council resolution last week that closed the mandate authorising military action.