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.
The assembly also voted for Giuma Attaiga, a lawyer from the port city of Misrata, as a deputy to Magarief, who had been seen as a leading contender for the top job. Voting for a second deputy will take place on Friday.
"He is a political personality and everybody knows him," Othman Sassi, a former official of the National Transitional Council, said of Magarief. "He has very good experience to lead congress and the Libyan democratic state."
Magarief is from Libya's second biggest city, Benghazi, the cradle of last year's revolt. Those roots are likely to placate fears in the east that the region would be marginalized by a centralized authority in the capital Tripoli.
The national assembly began life on Wednesday after it took power from the National Transitional Council, the political arm of the opposition forces that toppled Gaddafi a year ago and which has now been dissolved.
The ceremony was the first peaceful transition of power in Libya's modern history, but it has been overshadowed by several violent incidents in the past week that have underscored the country's precarious stability.
These include a car bomb near the offices of the military police in the capital, Tripoli, and an explosion at the empty former military intelligence offices in Benghazi.
In the new assembly, 80 seats are held by parties. A liberal coalition led by wartime rebel prime minister Mahmoud Jibril won 39 of those seats, while the Justice and Construction Party - the political wing of the Muslim Brotherhood - won 17.
The remaining 120 seats are in the hands of independent candidates whose allegiances are hard to pin down. Key decisions will require a two-thirds majority to pass, making cooperation necessary in what is still a delicate transition for Libya.