Prince William has been commissioned as an officer in the British Army after graduating from Sandhurst.
The Queen, Prince Charles and other members of the royal family attended a parade marking the end of his training at the royal military academy.
His girlfriend Kate Middleton also watched the 24-year-old prince, who is second in line to the throne.
William, who has been described by fellow trainee officers as "a normal guy", will become a 2nd Lieutenant.
The ceremony comes the day after the official investigation into the death of William's mother, Princess Diana, concluded she died in an accident.
Both William and his brother Prince Harry welcomed the "conclusive findings" of Thursday's report by Lord Stevens and called for speculation surrounding their mother's death to come to an end.
The Sandhurst ceremony involved up to 465 cadets, including 78 women, with more than 220 officer cadets such as the prince passing out and receiving their commissions.
Prince William acted as a marker during the Sovereign's parade to ensure the cadets marched in a straight line.
He will officially be awarded the title of 2nd Lieutenant at midnight.
The Queen, dressed in a dark red hat and coat, inspected the cadets and stopping briefly in front of her grandson to say a few words which made the prince smile.
She then said in a speech to all the graduating trainees that a "great deal" was expected of them.
"You must be courageous, yet selfless, leaders yet carers, confident yet considerate and you must be all these things in some of the most challenging environments around the world," she said.
The Duke of Edinburgh, the Prince of Wales and William's stepmother the Duchess of Cornwall were also attending the ceremony.
It is the first occasion that Ms Middleton has been Prince William's guest at a high-profile public event that is also attended by the Queen and other senior royals.
She arrived at the ceremony dressed in a black hat and scarlet coat and was joined by her parents Carole and Michael and the prince's private secretary Jamie Lowther-Pinkerton.
Junior Under Officer Angela Laycock, who is in the prince's Blenheim Platoon, earlier said the prince was not regarded any differently by his fellow cadets.
Miss Laycock, 24, said: "He's just a normal guy that gets stuck in like everybody else."
On riot training he had been "grabbing potatoes and lobbing them at the force protection people just like the rest of us," she said.
Major General Peter Pearson, Commandant of Sandhurst, said the prince had undergone the same gruelling regime as other trainee officers.
Becoming an officer "takes a lot of hard work", he said.
The prince has chosen to join the Household Cavalry's Blues and Royals alongside his brother Prince Harry, who graduated from Sandhurst earlier this year.
Both princes have indicated they are prepared to fight in zones of conflict.
The Prince has expressed a wish to serve in combat
Major General Sebastian Roberts, general officer commanding the Household Division and Prince William's new boss, indicated it was possible that the prince could be deployed to a conflict zone.
"Of course there are special factors for William, but nothing should be ruled in or out," he said.
He added that the prince had done "very well" at the military academy in Camberley, Surrey.
The prince will now spend four months at Bovington Camp in Dorset, training to become a troop commander in an armoured reconnaissance unit.
Unlike Prince Harry who will continue as a "career soldier", Prince William will go on to spend time with both the RAF and the Royal Navy on familiarisation attachments to prepare him for his future role.
He will increasingly carry out public engagements in parallel to his military career.