Leaving the European Union could hamper the UK's ability to tackle threats such as Islamic State or Vladimir Putin's Russia, former senior military commanders have warned.
The ex-service chiefs said Europe faced a series of "grave security challenges" and the UK was in a "stronger" position to deal with them from inside the EU.
The intervention by the former Royal Navy, Army and Royal Air Force will be a boost to David Cameron, but comes amid fresh warnings about the scale of the migration crisis in Europe.
In a letter to The Telegraph, the former commanders told of their concern about the rise of IS, also known as Daesh, saying: "We have served around the world and in almost every conflict in which Britain has been engaged since the Second World War.
"We are proud to have served our country and to have played our part in keeping Britain safe. In the forthcoming referendum, therefore, we are particularly concerned with one central question: will Britain be safer inside the EU or outside it? When we look at the world today, there seems to us only one answer.
"Europe today is facing a series of grave security challenges, from instability in the Middle East and the rise of Daesh, to resurgent Russian nationalism and aggression.
"Britain will have to confront these challenges whether it is inside or outside the EU. But within the EU, we are stronger. Inside it, we can continue to collaborate closely with our European allies, just as we did when we helped to force the Iranians to the negotiating table through EU-wide sanctions, or made sure that Putin would pay a price for his aggression in Ukraine."
Signatories to the letter, which was in part co-ordinated by Downing Street, include former chiefs of defence staff Field Marshal Lord Bramall and Field Marshal Lord Guthrie.
Air Chief Marshal Lord Stirrup, Admiral of the Fleet Lord Boyce and former special forces chief General Sir Michael Rose are also among the 13 senior officers who backed the letter.
The intervention by the top brass came as figures revealed the scale of the migration crisis in Europe.
The International Organisation for Migration said more than 102,500 people had crossed into Greece since January 1 and another 7,500 streamed into Italy over the same period. Similar figures were not reached last year until June.
As well as the potential for a repeat of last summer's migrant crisis in the Mediterranean coinciding with the June 23 referendum, the Prime Minister faced claims that his new deal with Brussels would do nothing to cut the number of EU citizens legally coming to the UK.
Campaign group Migration Watch UK said its research showed the "emergency brake" on paying in-work benefits to EU migrants in the UK "might not in fact have any significant impact".
The report - which has been dismissed by Number 10 - suggested that the introduction of the higher National Living Wage would counteract any deterrent that the welfare curbs might have.
In a sign of public concern over the issue, a ComRes poll for the Daily Mail found 62% believed net migration from the EU was too high and 74% thought the PM's deal would either have no impact on the numbers coming or could increase them.
The poll found 51% said they would vote for the UK to remain in the EU and 39% would leave.