By Marie-Louise Gumuchian and Ali Shuaib
TRIPOLI, Sept 12 (Reuters) - Libya's national congress picked Mustafa Abu Shagour as prime minister on Wednesday, the U.S.-trained optical engineer naming improved services and security as his priorities a day after Islamist gunmen killed the U.S. ambassador to Libya.
Abu Shagour defeated wartime rebel premier Mahmoud Jibril in a close second round vote by 96 votes to 94 in a contest that was shown live on national television.
As government chief he will be responsible for the day-to-day running of Libya's oil-based economy while the national congress elected in July passes laws and helps draft a new constitution for the North African state.
It will be put to a national referendum next year.
"There is so much to do," Abu Shagour told Reuters after his win, citing improving security and providing services as a priority for his new government.
The vote was overshadowed by the killing of the U.S. ambassador to Libya, Christopher Stevens, and three other Americans in an attack on the U.S. consulate and a safe house refuge in Benghazi.
"It makes security high on my priorities," he said.
While the interim government has restored many services and a semblance of normal life to Libya after the violent overthrow of long-time ruler Muammar Gaddafi, it has struggled to impose its authority over a myriad of armed groups who refuse to lay down their weapons.
Abu Shagour is regarded as being closer to Libya's de facto head of state, national congress head Mohammed Magarief, than the man he defeated.
However, he will have to cooperate with Jibril's liberal National Forces Alliance coalition which won 39 out of 80 seats attributed to parties in the July election.
Another 120 seats in the 200-member congress are held by independents whose affiliations are hard to pin down. The balance of forces will become clearer once Abu Shagour names his cabinet, probably by the end of this month.
Foreign companies, notably oil majors keen for a stake in Libya's lucrative oil fields, hope the new government will prove able to make major decisions, unlike the previous administration which lacked a popular mandate.
The incoming prime minister carved out a career as an academic in the United States, where he did some work for the U.S. space agency NASA, before returning to Libya last year where he was an adviser to the now dissolved National Transitional Council.
He was appointed a deputy to Prime Minister Abdurrahim El-Keib in November and honed his negotiating skills in government, acting as Tripoli's point man on a number of delicate national and international assignments.
In March, he led a delegation to Mauritania to seek the extradition of Gaddafi's former spy chief Abdullah al-Senussi, who was eventually flown to Tripoli last week.
Abu Shagour has also travelled frequently to the south of Libya to negotiate between the country's fractious tribes.