One of Boris Johnson's first tasks once he officially becomes prime minister will be to write a letter of last resort, which is carried on board each of Britain's nuclear submarines.

For more than five decades the UK has maintained a continuous at-sea deterrence - with at least one nuclear ballistic missile submarine on patrol since 1969.

Four Vanguard-class submarines carry Britain's Trident missiles and warheads.

The identical handwritten letters of last resort are located on each of the four submarines inside a Russian-doll like safe system, and are addressed to the commanding officer of each boat.

The letter gives instructions on what the crew should do in the event Britain is destroyed and the submarines lose contact with London as a result of a devastating conflagration.

The Letters of Last Resort will give orders to the four submarine commanders of Britain's Trident nuclear fleet on what to do.

Video Loading

The prime minister's decision on whether Britain should retaliate with a nuclear strike, or whether the submarines should head for a neutral port, or some other course of action, will never be made public.

Theresa May's instruction letters will be removed from nuclear strike force submarines and be destroyed, unopened, when she leaves office.

The moment the newly appointed prime minister writes the letters is said to be profound.

Former chief of defence staff Lord Guthrie said that Tony Blair "went quiet" when he had to write the letters.

In a BBC Radio 4 documentary, Lord Guthrie said: "I think quite honestly, like most prime ministers, he hadn't given a huge amount of thought to what this really meant. And it is actually an awesome responsibility.

"It really comes home to you that he could, if the circumstances demanded it, create devastation on a huge scale."

Commodore Bob Anstey, assistant chief of staff submarines, said: "The Prime Minister is alone when they write the letter.

"They get briefed on what it is for, why it exists and then they are left alone, given some paper, a shredder and some envelopes.

"Any drafts they have made, they shred them themselves so no one ever sees it. Then the envelopes are couriered up and put in the safe."

Johnson will also be in charge of any decision to launch the missiles if a conflict erupts. The launch order would be sent through to the boat in an encrypted 15-letter message.

Once it is received, after being transmitted across all sorts of airwaves to ensure delivery, there is a process on board to decode the message of letters and numbers, and then to verify it.

This is done using crypto books which are kept in the safe system that is located in the control room of each submarine - with part of the message instructing which page to use.

If the order to launch is legitimate, then the commanding officer would proceed to move the submarine into the required position.

A number of keys are then inserted into specific panels on the submarine, with all having to be turned and "lined up" for the system and trigger to work.

Cdre Anstey said the trigger itself is based on the handle of a pistol, is red, and stored in the missile control centre.