At King Charles’s request, Prince Harry wore military uniform, for the first time since 2020.
Prince Harry has worn civilian clothes at public events since the Queen died.
It is the first time in history that the grandchildren of a monarch have taken part in the ceremony.
The King’s sons William and Harry were joined by Peter Phillips and Zara Tindall, the children of Princess Anne, as well as Prince Andrew’s daughters, Princesses Beatrice and Eugenie, and Lady Louise Windsor and James, Viscount Severn, who are Prince Edward’s children.
At 44, Peter Philips is the oldest of the Queen’s grandchildren, while the youngest, James, Viscount Severn, is 14.
In silence and with their heads bowed, the eight cousins stood at different points around the coffin as crowds continued to file past.
Prince William stood at the head of the Queen’s coffin with his brother at the opposite end.
The Earl and Countess of Wessex, the parents of Louise and James, looked on from a platform facing the coffin.
The grandchildren’s vigil started at 18:01 BST and lasted for just under 15 minutes.
On Friday evening, the Queen’s children, including the King, took part in a similar vigil, standing guard for about 10 minutes.
Ahead of the vigil, Beatrice and Eugenie paid tribute to their “dear Grannie”, saying: “It has been the honour of our lives to have been your granddaughters and we’re so very proud of you.”
In a joint statement, they said the Queen was “our matriarch, our guide, our loving hand on our backs leading us through this world” and that they already miss her “terribly”.
They went on: “Thank you for making us laugh, for including us, for picking heather and raspberries, for marching soldiers, for our teas, for comfort, for joy.
“You, being you, will never know the impact you have had on our family and so many people around the world.
“The world mourns you and the tributes would really make you smile. They are all too true of the remarkable leader you are.”
The pair told the Queen they were “so happy you’re back with Grandpa” and added that “our dear Uncle Charles, the King, will continue to lead in your example as he too has dedicated his life to service”.
This was another poignant image, mixing the grandeur of a public ceremony with the intimacy of personal family memories. The Queen’s grandchildren were standing vigil around her coffin, with the queue of people flowing either side of them.
The people who had queued for many hours, bringing their own memories, shared the big silence of Westminster Hall with the royal grandchildren.
Prince Harry wore a Blues and Royals uniform and wearing the same uniform, on the other side of the coffin, was his brother Prince William.
Princess Beatrice and Princess Eugenie took their place in the vigil. In a tribute this afternoon they’d talked of the loss of “our dearest grannie”.
With the tap-tap-tap of a soldier’s sword on the stone, time was up. They finished their vigil and followed Prince William back out of the hall.
The vigil on Saturday was the first time Prince Harry had been seen in military uniform since stepping back as a working royal in 2020.
He served two tours in Afghanistan as part of the Army. He now lives in California with his wife Meghan and their two children.
The Duke of Sussex was wearing the Blues and Royals No 1 uniform, the same uniform as his brother.
Prince William has completed more than seven years of full-time military service, including three-and-a-half years as a search and rescue pilot.