Image copyright PA Image caption Mr Cameron signed a security partnership with his Algerian counterpart

Prime Minister David Cameron has said the international community should use "everything at its disposal" to fight terrorism, on a visit to Algeria.

The recent hostage crisis, in which some 37 foreigners died, was "a reminder that what happens in other countries affects us at home", he said.

He also defended Western intervention in the conflict in neighbouring Mali.

He is the first British prime minister to visit the North African country since it became independent in 1962.

Following the recent siege at the In Amenas gas plant in the Sahara, in which up to six Britons lost their lives, Mr Cameron discussed the threat of terrorism with his Algerian counterpart Abdelmalek Sellal in the capital Algiers.

He announced that two had agreed a security partnership, including co-operation on border and aviation security, as well as joint action on trade, investment and education.

The UK has also invited Algeria to participate in a joint contingency planning exercise to share experience in responding to crisis situations.

"Both Britain and Algeria are countries that have suffered from terrorism and we understand each other's suffering," he said.

"What we have agreed is a strengthened partnership that looks at how we combat terrorism and how we improve security of this region. This should be about sharing our perspectives, about the risks and dangers that there are, but also sharing expertise."

'Safer world'

Before holding talks with senior government figures, he told reporters that the UK's focus was "very much about helping this neighbourhood to help itself".

Media playback is unsupported on your device Media caption David Cameron: ''What I want to do is make sure we do everything we can to combat terrorism''

He said he wanted to "work with the Algerian government and with other governments in the region to make sure we do everything we can do to combat terrorism in a way that is both tough and intelligent, and uses everything we have at our disposal, which will make them safer, make us safer, make the world safer".

The UK announced on Tuesday it is to send 330 military personnel to Mali and west Africa to support French forces battling Islamist militants.

The deployment will include as many as 40 military advisers in Mali and 200 British soldiers in neighbouring African countries, to help train the Malian army.

Critics have warned of "mission creep", but Mr Cameron said the UK was an "open, international" country and, linking instability in north and west Africa to British national interests, said the country's "posture" was to protect its citizens around the world.

After he had laid a wreath at the martyrs memorial in Algiers, I asked him if he could allay fears that this region could become his Iraq or Afghanistan. He insisted that it would not.

But Mr Cameron said the UK and its allies "don't look at this region of the world and think that the answer is purely a military one".

"What is required in countries like Mali, just as countries like Somalia on the other side of Africa, is that combination of tough approach on security, aid, politics, settling grievances and problems."

BBC political editor Nick Robinson said the prime minister, who earlier laid a wreath at the martyrs memorial in Algiers and met British Embassy staff, was keen to use this trip to address fears that he is risking a protracted military engagement in north Africa.

He wanted to stress the situation in Mali would not become "another Afghanistan or even another Libya", our correspondent, who is travelling with the government entourage, added.

The PM's national security advisor Kim Darroch, the head of foreign security service MI6 Sir John Sawers and trade minister Lord Risby are accompanying Mr Cameron.