April 7 (UPI) -- Prince William spent three weeks with three of Britain's security and intelligence agencies, the royal family revealed late Saturday.
The Duke of Cambridge's "attachment" was with the Security Service, known as MI5; Secret Intelligence Service, MI6; and the Government Communications Headquarters, according to news release.
"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 in a statement.
"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."
He noted the dangers of their work.
"They are driven by an unrivalled patriotism and dedication to upholding the values of this country," he said. "We all owe them deep gratitude for the difficult and dangerous work they do."
The prince's assignment began with a week at MI6, whose agents work secretly overseas developing foreign contacts and gathering intelligence "to make the UK safer and more prosperous," according to the news release. The agency was portrayed by the James Bond series of novels and films.
The second week was with MI5, which protects national security, particularly against threats from terrorism.
His last assignment was at GCHQ, an agency that "uses cutting-edge technology, technical ingenuity and wide-ranging partnerships to identify, analyse and disrupt threats."
The threat level for international terrorism in Britain has been at "severe" or above for the last five years.
Last January, the former head of MI5, Baroness Manningham-Buller, warned Britain would be "less safe" if it leaves the European Union without a deal.
"Having The Duke of Cambridge spend time with our teams was an incredible opportunity," said the head of counter-terrorism operation only identified as David. "William worked exceptionally hard to embed himself in the team and comfortably held his own amongst some highly skilled analysts and operators."
The official said the prince was insightful.
"His Royal Highness asked some probing questions and demonstrated a real grasp of our mission," he said. "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."
William has worked in the military. He was an officer cadet trainee in the British Army and then was search-and-rescue pilot in the Royal Air Force for four years.
Later this month, William will visit New Zealand to honor the 50 victims of the mass shooting at mosques two weeks ago.