The British prime minister has made a surprise visit to the Libyan capital for talks centred on security, just days after his government, which played a key role in Libya's revolution, warned of threats to its embassy.

David Cameron flew into Tripoli on Thursday morning before his entourage was ringed by security, then headed to a police academy for a ceremony to mark the promotion of officers, accompanied by Ashur Shwayel, the Libyan interior minister.

"I will never forget the scenes I saw in Tripoli and [the eastern city of] Benghazi," Cameron said soon after arriving in the North African country, in reference to the 2011 revolution that toppled Colonel Muammar Gaddafi.

"The British people want to stand with you and help you deliver the greater security that Libya needs," he was quoted by the BBC as saying.

"We look forward to working together in the years ahead."

Security co-operation

A Libyan official told AFP news agency that security co-operation would top Cameron's agenda during his talks in Tripoli.

Downing Street said on Twitter that Cameron travelled to Tripoli "to discuss how the UK can continue to help build a strong, prosperous, democratic" Libya.

The British embassy in Tripoli tweeted that Cameron was in Libya "to reiterate UK support for Libya's transition".

On January 24, Britain urged its nationals to leave Benghazi immediately because of a "specific and imminent threat to Westerners" in the city on Libya's east coast.

Several other Western nations followed London's lead and advised their citizens to pull out.

That drew anger from Libya, which said the threat had been exaggerated and that there was "no new intelligence" to justify such concerns in the city that was the cradle of the uprising against Gaddafi.

Benghazi attack

On September 11 last year, Chris Stevens. the US ambassador to Libya, and three other people were killed when dozens of heavily armed al-Qaeda-linked fighters overran the US diplomatic compound and a nearby CIA-run annex in Benghazi.

Britain had closed its mission in the city around the same time and updated its official advice to warn against travelling there, and indeed to most of Libya.

Cameron paid a visit to 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.

His spokeswoman said before his departure that Cameron would seek a partnership with Algeria on tackling extremism, reflecting growing concern in the UK about unrest in North Africa, and in Mali.

Cameron was accompanied by his national security adviser and a trade envoy, Downing Street said, while British reports said the head of foreign intelligence service MI6 was also on the trip.

Source: Agencies