Libya's ruling council has handed over power to a newly elected national assembly in the North African country's first peaceful transition of power in its modern history but which comes amid heightened violence.
In a late-night ceremony held under tight security in Tripoli, the National Transitional Council (NTC), political arm of the opposition forces that toppled Muammar Gadafy a year ago, handed over to the national congress, elected in July.
NTC chairman Mustafa Abdel Jalil symbolically passed on the reins to the oldest member of the new 200-member assembly, Mohammed Ali Salim.
"The National Transitional Council hands over the constitutional duties for leading the state to the general national congress, which from now on is the sole legitimate representative of the Libyan people," Mr Jalil said to loud cheers.
In a speech, Mr Jalil, who announced he would retire after ending his NTC chief post, acknowledged "mistakes" had been made during an "extraordinary" transitional period and said security and disarmament issues had not been resolved in time.
The congress, whose members took an oath led by Mr Salim, will now name a new chairman while the NTC will be disbanded. A first meeting was scheduled after the ceremony.
Large crowds gathered in Tripoli's Martyrs Square to celebrate the handover as fireworks lit up the sky.
The assembly will name a new prime minister who will pick his government, pass laws and steer Libya to full parliamentary elections after a new constitution is drafted next year.
A liberal coalition led by wartime rebel prime minister Mahmoud Jibril won 39 of the 80 party seats in the congress, while its Islamist rivals, the Justice and Construction Party - the political wing of the Muslim Brotherhood - won 17.
However, the remaining 120 seats are in the hands of independent candidates whose allegiances are hard to pin down.
In the battle to hold sway over the assembly, where key decisions will require a two-thirds majority, Mr Jibril's National Forces Alliance and the JCP are scrambling to form alliances with independents and smaller parties.
Some independents, distrustful of both sides, have spoken of forming their own coalition.
Getting a grip on security in an often anarchic post-Gadafy Libya will be the priority for the country's new rulers, deputy prime minister Mustafa Abu Shagour earlier said.
The run-up to the transition has been overshadowed by several violent incidents in the past week that have shown the country's precarious stability.
These include a car bomb in Tripoli near the offices of the military police and an explosion at the empty former military intelligence offices in the eastern city of Benghazi, the cradle of the revolt against Gaddafi.
"Clearly they worry us, but at the same time we are investigating them. We are trying to find out who is behind this," Abu Shagour said. "We were able to improve security from when we started, but there's still a way to go. Security is top of the agenda for whomever will be coming into power."
The interim authorities that took over after Gadafy's overthrow successfully led Libya to the elections. But the government has struggled to impose its authority on a myriad of armed groups who refuse to lay down their weapons.
On Sunday, security forces killed three armed men suspected of being behind seven failed bomb plots. That same day, the International Committee of the Red Cross suspended its work in Benghazi and the port city of Misrata after one of its compounds was attacked with grenades and rockets.