The name is Wales, William Wales: licensed to kill three weeks on attachment with Britain’s spies.

Kensington Palace has revealed that the Duke of Cambridge has just finished a three-week stint at the secret intelligence service, MI6, the security service, MI5, and GCHQ.

The highly unusual internship was kept under close wraps as Prince William spent a week with each agency in what he said was a “truly humbling experience”.

It began with a week at MI6, whose officers work secretly overseas. In a statement, the palace said the prince had seen firsthand how the agency helped the UK identify and exploit opportunities, as well as navigate risks to its national security, military effectiveness and economy “from those who wish the UK harm”.

A second week, spent with MI5, saw William work alongside counter-terrorism teams to see how they conducted investigations, including understanding the role of analysis and surveillance. His final week was an assignment at GCHQ in Cheltenham, where the palace said he spent time learning how cutting-edge technology could be used to identify, analyse and disrupt threats.

The palace said that, with the threat level for international terrorism in the UK having been set at severe or above for the past five years, the prince was able to see firsthand the “extraordinary work that staff across the security and intelligence agencies do”.

“Spending time inside our security and intelligence agencies, understanding more about the vital contribution they make to our national security, was a truly humbling experience,” William said.

“These agencies are full of people from everyday backgrounds doing the most extraordinary work to keep us safe. They work in secret, often not even able to tell their family and friends about the work they do or the stresses they face. They are driven by an unrivalled patriotism and dedication to upholding the values of this country. We all owe them deep gratitude for the difficult and dangerous work they do.”

GCHQ’s head of counter-terrorism operations, who is identified only as “David”, said the prince’s time with the agency had given him valuable insight. “Having the Duke of Cambridge spend time with our teams was an incredible opportunity. William worked exceptionally hard to embed himself in the team and comfortably held his own among some highly skilled analysts and operators. His royal highness asked some probing questions and demonstrated a real grasp of our mission. This was a rare opportunity to expose, in detail, the technical ingenuity and problem-solving skills needed on a daily basis to help keep the UK safe.”

This is not the first time the prince has enjoyed a spell of work experience.

Before he attended Sandhurst, he did three weeks interning at several City institutions including the Bank of England, the London Stock Exchange and Lloyds of London.