David Cameron at Sandhurst cadets' passing out parade
The passing out parade of officer cadets has taken place at Sandhurst, witnessed by Prime Minister David Cameron.
Watched by thousands of the cadets' friends and relatives, Mr Cameron inspected troops at the Royal Military Academy on the Surrey border.
A total of 226 officer cadets were commissioned in the ceremony.
The district governor of Helmand Province also attended because two Afghan cadets were passing out.
Other dignitaries who had sons or grandsons passing out included the King of Swaziland, the President of Yemen, the Prime Minister of Bahrain and the Ruler of Umm Al Qaiwain in the United Arab Emirates.
Speaking to the cadets, Mr Cameron said: "As a government, we will do everything we possibly can to support you and look after your families and to rebuild the military covenant that is so important to our country."
He added: "People expect us to do the best by you.
"Yes, there will be difficult decisions ahead, but I will never forget that defence of the realm is the first duty of any government."
Many of the cadets were to be deployed to Afghanistan and the prime minister told them there would be "huge challenges" ahead.
He told them that as they left Sandhurst they should take with them pride in their achievements, pride in the Army and pride in what they were going to do.
"You have been through 44 weeks of the toughest and the best training that anyone can do," he said.
And he told them that if troops were to be withdrawn from Afghanistan now, the Taliban could seize that opportunity.
"I say we cannot let that happen," he said.
Mr Cameron, who was performing the duty on behalf of the Queen for the first time, also said it was a "huge privilege" for him to be at the Sandhurst ceremony.
After the ceremony the officer cadets paraded to music played by the Band of Rifles.
A party and funfair was being held in the grounds of Sandhurst on Friday evening.