London (CNN) Prince William, Duke of Cambridge, has completed a three-week attachment with the UK's Security and Intelligence Agencies, observing firsthand the country's fight against terrorism.

The Duke spent time at MI6, GCHQ and the Security Service, observing intelligence and counter-terrorism operations at the three agencies.

He was keen to observe the work of the groups and "held his own" among high-skilled analysts and operators, GCHQ's head of counter-terrorism operations.

The UK's terror level threat for international terrorism has been set as "severe" or above for the last five years.

"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.

Read More