As Britain and the world said a final goodbye to Queen Elizabeth at a state funeral on Monday, several of her children and grandchildren sported their military uniforms. 

Some only wore suits.

Buckingham Palace previously confirmed that only working members of the royal family would wear military uniforms during the events leading up to and including the late monarch’s funeral service. Prince Andrew and Prince Harry, who are no longer senior working royals, wore dark suits to join the procession.

Queen Elizabeth Funeral

William, Prince of Wales, Prince Harry, Peter Phillips, King Charles III, Anne, Princess Royal and Prince Andrew depart the state funeral of Queen Elizabeth II at Westminster Abbey on Sept. 19, 2022, in London. (Samir Hussein/WireImage)

Peter Phillips, the son of Princess Anne who walked behind his cousin Harry, also wore a suit as he doesn’t hold any military ranks. An exception was made for Harry, 38, and his uncle Andrew, 62, to wear their uniforms once during the mourning period.

Here’s how the military played a prominent role in the lives of the royals and why some are allowed to wear uniforms despite never serving:

QUEEN ELIZABETH II'S FUNERAL: COFFIN HEADS TO WINDSOR CASTLE FOR BURIAL AT ST. GEORGE'S CHAPEL

Queen Elizabeth II

Queen Elizabeth

Princess Elizabeth learning basic car maintenance as a second subaltern in the ATS, circa 1945. (Daily Mirror/Mirrorpix/Mirrorpix via Getty Images)

The late royal’s relationship with the armed forces began in 1945 when she joined the Auxiliary Territorial Service (ATS). As then-Princess Elizabeth, she became the first female member of the British royal family to join the armed forces as a full-time active member. During her time with the ATS, Elizabeth learned how to drive and maintain vehicles.

As queen, she maintained a close relationship with the armed forces and made regular visits to service establishments and ships. She was known for meeting servicemen and women, as well as their families. As sovereign, she was the head of the armed forces and held numerous military appointments and honorary ranks.

The late queen introduced the Elizabeth Cross, which was instituted in 2009. It gives special recognition to families who have lost loved ones during military operations, or as a result of terrorism. "I greatly hope that the Elizabeth Cross will give further meaning to the nation’s debt of gratitude to the families and loved ones of those who have died in the service of our country. We will remember them all," she said during her broadcast at the time.

Every year, Elizabeth led the nation to honor the fallen on Remembrance Sunday.

CLICK HERE TO SIGN UP FOR THE ENTERTAINMENT NEWSLETTER

King Charles III

King Charles

Prince Charles giving a thumbs up as he sits in the cockpit of a Royal Navy Wessex helicopter during a flying lesson, at the Royal Naval Air Station in Yeovilton, Somerset, Oct. 20, 1972. (Central Press/Hulton Archive/Getty Images)

Elizabeth’s eldest son served in the Air Force and Navy from 1971 until 1976. During his naval career, Charles followed in the footsteps of his father, grandfather and great-grandfathers. He trained as a jet pilot at the Royal Air Force Cranwell in Lincolnshire before enrolling in the Britannia Royal Naval College. Charles began his military service on the guided missile destroyer HMS Norfolk. He went on to serve on two frigates – the HMS Minerva from 1972 until 1973, and then the HMS Jupiter in 1974. He then received qualifications as a helicopter pilot before joining the 845 Naval Air Squadron aboard the HMS Hermes.

In 1976, Charles was given command of the coastal minehunter HMS Bronington. He also underwent parachute training. In 1995, Charles became group captain of the Royal Air Force. Eventually, Charles was granted an honorary five-star rank in all three of the armed forces. He became a field marshal, admiral of the fleet and marshal of the Royal Air Force.

Princess Anne

Princess Anne

Princess Anne, Princess Royal takes part in the procession following the coffin of Queen Elizabeth II in London on Sept. 19, 2022. (Sebastien Bozon/AFP via Getty Images)

While Elizabeth’s only daughter did not serve in the military, she does hold several military honors and titles. In 1993, she was made a rear admiral. She was promoted to vice admiral in 2009 and then admiral in 2012. In 2020, Anne was also made a general in the British Army, as well as an air chief marshal in the Royal Air Force. She is involved with over 300 charities, organizations and military regiments in the U.K. and overseas. Anne is known for devoting much of her life to supporting her charities, as well as carrying out official duties and visits.

QUEEN ELIZABETH'S FUNERAL HONORS LATE ROYAL'S 'LIFE-LONG SENSE OF DUTY' AT WESTMINSTER ABBEY

Prince Andrew

Prince Andrew

Prince Andrew, the Duke of York, on board HMS Invincible during the Falklands War, in which he served as a helicopter pilot. (© Hulton-Deutsch Collection/Corbis/Corbis via Getty Images)

The Duke of York spent 22 years in the Royal Navy where he served as a helicopter pilot in the Falklands War in 1982. However, he was stripped of his military titles and royal patronages in January 2022 after he was accused of sexual assault by Virginia Roberts Giuffre. Andrew was allowed to wear his military garb once – on Friday for a Vigil of the Princes. There, he joined his siblings in standing as a symbolic guard over their mother’s coffin at Westminster Hall.

Prince Edward

Prince Edward

Prince Andrew and Prince Edward attend the state funeral service for Queen Elizabeth II, at Westminster Abbey in London on Sept. 19, 2022. (Dominic Lipinski/Pool/AFP via Getty Images)

Elizabeth’s youngest son resigned from the Royal Marines in 1987. At the time, Buckingham Palace said, "Edward leaves the Marines with great regret but has concluded that he does not wish to make the service his long-term career." While the Earl of Wessex never actively served in the military, the palace noted he does support the work of the armed forces both in the U.K. and abroad. He holds eight military appointments.

In 2006, Edward was appointed commodore-in-chief of the Royal Fleet Auxiliary. The next year, Edward became the royal colonel of 2nd Battalion The Rifles following the reorganization of the infantry. He regularly visits the battalion at their base in Northern Ireland. He has also visited them several times while on operational duties, including in Afghanistan. In 2008, he became honorary air commodore of the Royal Air Force Waddington. According to the palace, Edward holds three military positions in Canada as colonel-in-chief of the Hastings and Prince Edward Regiment, the Prince Edward Island Regiment and the Saskatchewan Dragoons.

PHOTOS: QUEEN ELIZABETH II’S HISTORIC FUNERAL TAKES PLACE AT WESTMINSTER ABBEY

Prince William

Prince William

Prince William attends a service of commemoration to mark the end of combat operations in Afghanistan at St. Paul's Cathedral on March 13, 2015, in London. (Max Mumby/Indigo/Getty Images)

King Charles’ eldest son completed nearly eight years of full-time military service. William graduated from the Royal Military Academy Sandhurst and then went on to active duty in the Army, Navy and Royal Air Force. He became a civilian air ambulance pilot before moving into full-time royal duties five years ago.

The armed forces are a key focus of his charitable work. Over the years, he has raised awareness on the challenges service personnel endure as they make the transition to civilian life. The Prince of Wales is patron of the Royal Air Force Battle of Britain Memorial Flight and honorary air commandant of Royal Air Force Coningsby.

Prince Harry

Prince Harry

Prince Harry at the observation post on JTAC Hill on Jan. 2, 2008, in Helmand province, Afghanistan. (John Stillwell/Pool/ Tim Graham Picture Library/Getty Images)

King Charles’ youngest son served in the army for 10 years. He rose to the rank of captain and did two tours of Afghanistan. In 2005, he entered The Royal Military Academy Sandhurst to train as an officer cadet. In 2006, he was commissioned as an army officer. He joined his regiment that year before reporting to The Armour Centre at Bovington in Dorset to begin the Troop Leaders’ Course. According to the palace, his training "included instruction in signals, driving and maintenance, and gunnery." He then rejoined his regiment in Windsor, where he was responsible for a troop of 11 soldiers and four Scimitar reconnaissance vehicles.

In 2008, it was revealed that Harry had been serving with the British Army in Helmand, Afghanistan, for more than two months. That year, he was promoted to lieutenant with The Household Cavalry (Blues and Royals). In 2014, Harry founded the Invictus Games to aid the rehabilitation of injured or sick military members and veterans by giving them the challenge of competing in sports events.

QUEEN ELIZABETH II'S INSIGNIA MISSING FROM PRINCE HARRY'S UNIFORM, WORN BY PRINCE WILLIAM AND PRINCE ANDREW

Harry lost his three honorary military titles (captain general of the Royal Marines, honorary air commandant of RAF Honington and commodore-in-chief, Small Ships and Diving, Royal Naval Command) after he and his wife Meghan Markle stepped back from their senior royal roles in March 2020.

Following Elizabeth's death, a spokesperson for the Duke of Sussex told Fox News Digital that he will wear a "morning suit throughout events honoring his grandmother."

"His decade of military service is not determined by the uniform he wears, and we respectfully ask that focus remain on the life and legacy of Her Majesty Queen Elizabeth II," the spokesperson noted.

On Saturday, an exception was made for Harry, who wore his Blues and Royals uniform alongside his older brother William "at the King’s request" for a vigil honoring his grandmother.

The Associated Press contributed to this report.