Prince William was among 220 cadets graduating from Sandhurst. Following a 44-week course, they were being commissioned as officers in the British Army.
William is to train to be a troop commander in an armoured reconnaissance unit. He will now participate in a six-month course in Dorset.
The Queen stopped briefly in front of William as she inspected the platoons and said a few words, prompting the second-in-line to the throne to smile for a brief moment.
The Queen, accompanied by the academy's Commandant Major General Peter Pearson, inspected the new officers as they stood to attention.
The Prince of Wales and the Duchess of Cornwall also attended the ceremony at the military college in Surrey, where officers have trained since 1812.
William's girlfriend Kate Middleton watched as the prince took part in the Sovereign's Parade. He is to join the Household Cavalry's Blues and Royals like brother Harry.
Because he is 6ft 3ins, William acted as a marker at the end of the line to ensure the cadets marched straight.
Rather than sitting in the VIP seats, Kate sat with her parents on the front row.