David Cameron has made a surprise visit to Libya where he promised to help bolster the police and the army.
The Prime Minister said Britain was ready to provide training and advice amid growing concern about the security situation in the region.
On a walkabout in the capital's famous Martyrs' Square, Mr Cameron was greeted by locals.
At a press conference later on Thursday, he revealed that British police investigating the Lockerbie bombing are to travel to Libya.
The trip, expected in March, will be the first time police have been allowed to visit as part of the probe.
"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," Mr Cameron said.
The premier last visited Libya in September 2011, touring Tripoli and Benghazi shortly after Colonel Gaddafi lost his grip on power.
Sky's deputy political editor Joey Jones, speaking from Tripoli, said you could see there was "genuine affection" in Libya for the PM.
"People are crowding in on David Cameron, shaking his hand and saying hello. They are obviously very pleased to see him," he said.
The Prime Minister spent 10 to 15 minutes walking around the Square where security was tight, with black-clad security services trying to hold back locals and a helicopter flying overhead.
Jones said: "He feels he has forged a friendship with the Libyan people in what was their hour of need.
"Now he wants to demonstrate that he can take that friendship forward given that there are still immense challenges that face the country."
Mr Cameron was guided around the square, a key location in the revolution, by youth workers Abdurahman - who fought against Gaddafi - and Mervat.
Mervat and the organisation she set up, 3 Generation, tries to find information on those who went missing during the dictator's reign and the revolt.
Earlier, the Prime Minister toured a police training centre on the outskirts of Tripoli.
He told police recruits it was "very good to be back". "I will never forget the scenes I saw in Tripoli and Benghazi," he said.
"The British people want to stand with you and help you deliver the greater security that Libya needs.
"So we have offered training and support from our police and our military. We look forward to working together in the years ahead."
Mr Cameron is holding talks with counterpart Ali Zeidan and President Megarief while in the country.