Triploli - Libya's national assembly picked former opposition leader Mohammed Magarief as its president as the North African country's newly elected congress began its rule.
Magarief, seen as a moderate Islamist, will head the 200-member congress, which will name a prime minister, pass laws and steer Libya to full parliamentary elections after a new constitution is drafted next year.
Magarief, leader of the National Front party, is effectively acting head of state, but the true extent of his powers is yet to be determined. He beat a liberal candidate in the vote.
An economist and former Libyan ambassador to India who had lived in exile since the 1980s, Magarief was a leading figure in Libya's oldest opposition movement - the National Front for the Salvation of Libya - which made several attempts to end Muammar Gaddafi's rule.
The 72-year-old's National Front Party is an offshoot of the old opposition movement and won three seats in the July 7 poll - Libya's first free vote in a generation.
"I am very, very happy. This is a big responsibility," he told Reuters after the late night vote on Thursday.
Magarief won 113 votes versus independent Ali Zidan, who secured 85 votes. Voting went to a second round after no one managed to win an outright majority in the first.
"This is democracy. This is what we have dreamt of," Zidan told Reuters, congratulating Magarief.