Library image of the Duke of Cambridge (Picture: PA)
Prince William has spent three weeks gaining a better understanding of how the UK's security intelligence works.
According to Kensington Palace, he learned about the risks to the UK's national security, military effectiveness, and economy.
The Duke of Cambridge spent the first week with the MI6, which deals with foreign intelligence and protects the UK from risks abroad.
He then shadowed the Security Service (MI5) for a week, where he saw counter-terrorism teams in charge of analysing intelligence and conducting investigations on UK soil.
Finally, he worked at GCHQ, the Government's listening centre in Cheltenham, Gloucestershire, which monitors communications to look for potential security threats to the UK.
After his placement the Duke said: "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.
"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," he continued.
"We all owe them deep gratitude for the difficult and dangerous work they do."
GCHQ Head of Counter-Terrorism Operations, known only as David, said:
"Having the Duke of Cambridge spend time with our teams was an incredible opportunity.
The departments also said that His Royal Highness asked some "probing questions" which showed he has a real grasp on their mission.