Former CIA director David Petraeus speaks after leaving the Federal Courthouse in Charlotte, North Carolina, April 23, 2015. REUTERS/Chris Keane

LONDON (Reuters) - A British exit from the European Union would significantly weaken the bloc’s security, David Petraeus, a former U.S. military commander and CIA director wrote on Sunday, urging Britons not to vote to leave the union at a June referendum.

The comments, days after suicide bomb attacks killed 31 people in Brussels, support one of the British government’s key arguments in its campaign to win over undecided voters - that the country is safer inside the 28-country bloc.

“I encourage my British friends to think twice before withdrawing from one of the most important institutions that undergirds Western strength — the European Union,” Petraeus wrote in the Sunday Telegraph newspaper.

Polls show that public opinion is evenly split on whether to remain in the bloc. Survey results differ according to the methods used to canvas opinion, but polls last week suggested that support for an exit was rising and showed that many voters remain undecided.

Britain will vote in a referendum on the question on June 23.

He said that whilst a retreat into the “perceived safety of isolation” was tempting, history had shown such decisions were a strategic dead end.

“There is no question in my mind that a “Brexit” would deal a significant blow to the EU’s strength and resilience at exactly the moment when the West is under attack from multiple directions,” Petraeus wrote.

Former security chiefs are divided on the impact of a British exit.

Michael Hayden, ex-director of the CIA and the National Security Agency said on Friday that leaving the EU would have a limited impact on British security, and former UK foreign intelligence chief Richard Dearlove has said there could be security gains from an exit.