The Queen has left hospital in central London after being assessed for gastroenteritis symptoms.
She 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 the Queen, 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, she shook hands with hospital staff on the steps outside.
BBC correspondent Daniela Relph said the Queen looked "in pretty good condition and pretty healthy" as she left.
But 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, she 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.