The United Nations Security Council has voted to end international military operations in Libya next Monday.
In March the council voted to authorise "all necessary measures" to protect civilians, after then-leader Muammar Gaddafi launched a deadly assault on protesters against his rule.
Last week Nato and its partners, which had been conducting air strikes, said the campaign would end on 31 October.
Libya's new government declared the country liberated on Sunday.
On Thursday the council unanimously approved a resolution ending the mandate for foreign military action at 23:59 Libyan time on 31 October.
UK Foreign Minister William Hague said the vote was a "milestone towards a peaceful, democratic future for Libya".
The resolution came despite a call by Libya's National Transitional Council (NTC) for Nato to continue its military action.
The Libyan envoy to the UN had said the NTC needed more time to assess its security needs.
But Security Council diplomats told reporters that the mandate to protect civilians had been accomplished, and any further security assistance would have to be negotiated separately.
Nato Secretary General Anders Fogh Rasmussen said the UN resolution "reflects that we have accomplished our mandate to protect the civilian population of Libya".
He said he did not expect Nato to have a major role in post-conflict Libya.
"If requested we can assist the new Libyan government in the transformation to democracy, for instance with defence and security sector reform, but I wouldn't expect new tasks beyond that," he said.
During its seven-month Libyan campaign, the alliance has carried out some 26,000 sorties and almost 10,000 strike missions.
Correspondents say the operations have played a crucial role in helping remove Col Muammar Gaddafi, who was toppled in August and killed last week.
Russia, China, South Africa, India and Brazil had strongly opposed the strikes, accusing Nato of going beyond the UN mandate.
But on Thursday the US envoy to the UN, Susan Rice, said history would regard the intervention as "a proud chapter in the Security Council's experience".
Meanwhile, UK officials have been working to prevent the proliferation of weapons left over from Gaddafi's rule.
"We're trying to get to the bottom of what might be there and what might not be there," the UK's head of Joint Operations, Air Marshall Sir Stuart Peach, told reporters on Thursday.
A team of UK experts have been working alongside Libyan and US counterparts since September to track down man-portable air defence systems (Manpads), the British ministry of defence said.
More than 800 bunkers across Libya have been inspected so far, a spokesman said.