The Queen had been at London’s King Edward VII’s Hospital since Sunday – her first hospital stay in 10 years.
All official engagements for this week, including a visit to Rome, were either cancelled or postponed. She also missed St David’s Day celebrations in Swansea.
Buckingham Palace said Queen Elizabeth, 86, was admitted as a precaution and was otherwise in “good health”.
On Monday afternoon, a Bentley took the Queen to Buckingham Palace, where she will spend the night.
Dressed in a red coat and smiling, the Queen shook hands with hospital staff on the steps outside.
A Palace spokeswoman confirmed the Queen’s diary for this week would remain suspended.
She said: “Engagements cancelled or postponed this week remain so.
“Next week, we’ll have to see, as she has only just been released from hospital.”
On Saturday, the Queen had missed the military ceremony in Wales due to the stomach bug.
On Sunday, the Queen was driven from Windsor Castle, where she had been resting, after carrying out a private medal presentation earlier in the day.
A spokesman for the Queen said she was in “good spirits” and her admission was “a precautionary measure”.
Gastroenteritis causes inflammation of the stomach lining and intestines.
The infection can be transmitted through contact with an infected person or contaminated food and drink. Symptoms can include vomiting, fever and stomach ache.
The Queen’s treatment, which has not been disclosed, may have included rehydration and tests to establish if the illness was caused by an infection or an underlying problem.
The Queen last received treatment 10 years ago, again at the King Edward VII’s hospital, for a minor knee operation. At the same time, surgeons removed minor, non-cancerous lesions from her face.
Next weekend, she had been due to spend two days in Rome with the Duke of Edinburgh, at the invitation of Italy’s President Giorgio Napolitano.
It is not clear whether the visit will be re-scheduled.
A reception at Buckingham Palace on Tuesday for MPs and MEPs will go ahead with other members of the Royal Family present.
RDE-LHffrDcThe US House Ethics Committee has voted to release its report on former Republican Representative…
ABC News has agreed to pay $15 million to President-elect Donald Trump to settle a…
South Korea’s parliament has voted to impeach President Yoon Suk Yeol over his failed attempt…
Israeli war planes have carried out more than 100 air strikes in Syria on December…
President-elect Donald Trump has threatened to impose 100% tariffs on the BRICS countries if they…
Syrian troops have withdrawn from the city of Aleppo following an offensive by rebels opposed…