David Cameron has pledged help to bolster the police and army in Libya as he made an unannounced visit to the country.
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 friendly locals.
The premier last visited Libya in September 2011, touring Tripoli and Benghazi shortly after Colonel Muammar Gaddafi lost his grip on power.
Mr Cameron was guided around the square, a key location in the revolution, by youth worker 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 due to hold talks with counterpart Ali Zeidan and President Megarief while in the country.
Security was tight on the visit to Martyrs' Square, with black-clad security services trying to hold back locals and a helicopter flying overhead.