British Prime Minister David Cameron made a surprise visit to Tripoli on Thursday for security talks just days after his government, which played a key role in Libya's revolution, warned of threats to its nationals.
He flew to Tripoli from Algeria and was welcomed amid tight security.
"I will never forget the scenes I saw in Tripoli and (the eastern city of) Benghazi," Cameron said of the 2011 revolution that toppled long-time dictator Moamer Kadhafi.
"The British people want to stand with you and help you deliver the greater security that Libya needs," a statement from the prime minister's office said.
"So we have offered training and support from our police and our military. We look forward to working together in the years ahead."
Speaking to reporters, Cameron said British police investigating the 1988 bombing of a passenger jet over the Scottish town of Lockerbie, which killed 270 people, would visit Libya.
"I am delighted that the Dumfries and Galloway police team will be able to visit your country to look into the issues around the Lockerbie bombing," he told a joint news conference with his Libyan counterpart Ali Zeidan.
Libyan Abdelbaset Ali Mohmet al-Megrahi, the only person convicted of the bombing, died of cancer last May, almost three years after the Scottish government freed him from jail on compassionate grounds.
Cameron also said police investigating the murder of policewoman Yvonne Fletcher, killed outside the Libyan embassy in London in 1984, had been able to come to Tripoli three times since the 2011 revolution.
He said that would have been "unthinkable" before Kadhafi was toppled and killed in 2011.
"We are your friends. We are your supporters. We want to work with you, to stand with you (to) build a safe, secure and prosperous democracy here in Libya," he said.
Downing Street said Cameron "agreed a new package of support with a focus on military, police and border security advisers" during the visit.
Signup to our newsletter and follow us on Facebook and Twitter!
"In addition to training being provided in Libya, a group of Libyan sailors are to be given the opportunity to train in the UK with the Royal Navy."
"British expertise will also help the first freely elected government in Libya for 40 years to cement democracy ... The UK will provide a justice adviser (and) training for domestic electoral observers," it added.
On January 24, Britain urged its nationals to leave Benghazi immediately because of a "specific and imminent threat to Westerners" in the eastern coastal city, a move matched by several other Western nations.
That sparked anger from Libya, which said the threat had been exaggerated and there was "no new intelligence" to justify such concerns in the city that was the cradle of the uprising against Kadhafi.
Britain had closed its mission in Benghazi around the same time and updated its official advice to warn against travelling there and indeed to most of Libya.
On Monday, Britain said it had also identified a "potential threat" to its embassy in Tripoli.
The Foreign Office, which already warns against "all but essential travel" to Tripoli, said its travel advice remained unchanged.
Cameron visited Algeria on Wednesday to strike a new security partnership between the two countries, little more than two weeks after a deadly hostage crisis at a Sahara gas plant in that country.
Six Britons are believed to have been among 37 foreign hostages killed when gunmen stormed the plant and the Algerian army launched a military assault.
One Algerian hostage and 29 gunmen were also killed.
Cameron's spokeswoman said before his departure that Cameron would seek a partnership with Algeria on tackling extremism, reflecting growing concern in London about unrest in North Africa, and in Mali.
"Libya is strategically important in combating terrorism in North Africa -- especially in light of recent events in Mali and Algeria," Downing Street said.