Hundreds of British troops will be deployed to Somalia and South Sudan to train African peacekeeping forces in order to foster “less terrorism and less migration”, David Cameron has said.

The prime minister said he was offering forces to United Nations (UN) and African Union (AU) missions to help tackle conflicts that are facilitating the rise of terrorist groups in Somalia and prompting mass migration from South Sudan, where 2 million people have been displaced by the battle between the government and rebels.

About 70 members of the military personnel will be offered to help in Somalia, where a peacekeeping unit is present to tackle the threat of the Islamist group al-Shabaab. They will not be involved in combat operations but will help train AU forces in areas including logistics, engineering and medical aid.

Further troops – about 250 to 300 over the course of several missions – are being sent to carry out specific tasks in South Sudan, such as engineering advice and combat training.

Cameron will offer the troops at a session on UN peacekeeping on Monday, hosted by the secretary general, Ban Ki-moon, and the US president, Barack Obama, with dozens of other member states expected to make contributions.

Speaking before his arrival in New York, Cameron said: “We think Britain has a particular role in training and logistics and expertise and standards, so we want to step up what we are doing. But let me stress, we all want to see all the right force-protection arrangements in place but we should be playing a part in this.

“What happens in Somalia, if it’s a good outcome, it’s good for Britain, it means less terrorism, less migration, less piracy; ditto South Sudan.”

He said it was “absolutely vital that the international community works together to shore up stability in Africa”.

The UK has contributed to many peacekeeping forces over the years, wearing the distinctive blue berets of the UN, but its role is largely limited now to providing about 280 troops participating in the current mission in Cyprus.

About £260m has been given in aid to South Sudan since the start of the civil war in December 2013. But the British government has in recent years come under pressure to contribute more in the way of boots on the ground to bolster the UN’s peacekeeping aims.