LONDON—The royal family will unite in procession Wednesday to move Queen Elizabeth II’s coffin from Buckingham Palace to Westminster Hall in London, where it will lie in state for four days before her state funeral.

King Charles III was joined by his sons, Prince William and Prince Harry, and the wider royal family in what a senior aide described as the coffin’s transition “from family to state”—from lying in Balmoral and Buckingham Palace surrounded by family to lying in Westminster Hall for the public to mourn.

The period of national mourning is moving toward its final denouement Monday, when the state funeral is expected to draw a million people and heads of state from around the world.

At Westminster Hall, a historic building that dates to 1097, the coffin was placed on a raised platform called a catafalque, along with a 24-hour vigil by soldiers. After a short service, the doors opened and the first members of the public began to shuffle through and pay their respects. Most paused briefly in front of the flag-draped coffin, bowed their heads, and walked on.

The line to enter Westminster Hall was nearly 3 miles long by the time the building was opened to the public, forming just outside parliament, crossing the River Thames, and snaking along the river past landmarks like the London Eye and down to Tower Bridge. The government has warned that in the coming days, the line could grow to 10 miles long, forcing people to wait overnight.

“I will stay here, however long it is,” said Jo Maxwell, 53, from London as she stood in line.

Earlier, a large crowd gathered outside Buckingham Palace and along the route from the palace, watching in silence as the procession, led by drummers beating at 75 steps a minute, made its way down the Mall, which was bordered with red, white and blue U.K. flags, through Whitehall, Parliament Square and into Westminster Hall.

The procession lasted 38 minutes, with Big Ben tolling every minute.

The coffin, carried on a gun carriage that also carried Queen Elizabeth’s father and grandfather’s coffins, was draped in the royal flag and adorned with the imperial state crown on a purple velvet cushion and flowers, including foliage from royal residences in Balmoral and Windsor.

Grenadier and Scots guards dressed in red uniforms and tall bearskin caps marched in front of the procession, while a band played funeral marches from Beethoven, Mendelssohn and Chopin. There were no flights overhead to disrupt the solemn occasion, as Heathrow Airport delayed flights during the procession, airport officials said.

Every detail was meticulously planned by palace officials, in some cases for many years. The black horses pulling the gun carriage had been exposed to sobbing noises to ensure they weren’t flustered by emotion in the crowd.

In a show of unity, King Charles’s children, Prince Harry and Prince William, joined his siblings Prince Andrew, Princess Anne and Prince Edward to accompany the procession on foot. Their respective partners traveled by car.

Members of the family were dressed in full military uniforms, except for Prince Andrew and Prince Harry, who weren’t allowed to wear their military uniforms because they are no longer working members of the royal family.

The ceremony marks a period of conciliation among a strained family. Prince William fell out with his brother, after the latter quit royal duties and moved to the U.S. with his wife Meghan, Duchess of Sussex. Prince Andrew, meanwhile, was barred from royal duties by the queen after he settled a federal sex-abuse lawsuit. A spokesperson declined to comment.

The images of William and Harry walking behind the queen’s coffin evoked a similar somber occasion 25 years ago, when they both walked slowly behind the coffin of their mother Diana, Princess of Wales.

A lying-in-state for a former monarch is a relatively recent tradition. King Edward VII was the first former sovereign to lie-in-state at Westminster Hall in May 1910, followed by George V in 1936 and George VI in 1952.

Tens of thousands of people said a final farewell to Queen Elizabeth II in the Scottish capital of Edinburgh on Tuesday, before her coffin was flown to London last night.

The king is expected to travel to Wales on Friday.