Her Majesty, who will be 87 next month, spent less than 24 hours at the King Edward VII Hospital in London after falling ill at Windsor Castle on Sunday.
Buckingham Palace had suggested that she was likely to stay in hospital for "a couple of days" but the Queen emerged from the hospital at 2.43pm looking well and smiling broadly as she thanked staff and shook hands with a nurse.
Her treatment for gastroenteritis will have involved making sure she did not get dehydrated, possibly by drip-feeding fluids to the monarch.
Palace sources said she remained "in good spirits" but would still spend the rest of the week resting. Her next public outing is scheduled to be next Monday, when the Queen will carry out a day of Commonwealth-related engagements, including a service at Westminster Abbey where Her Majesty will address a 2,000-strong congregation.
The Queen had been driven by private car from Windsor to the hospital on Sunday afternoon on the advice of her physician, Prof John Cunningham. Despite the fact she appeared in good health and good spirits otherwise, Prof Cunningham felt the “assessment of her health could better be carried out in hospital”, royal sources said.
She had brushed aside any suggestion of receiving royal visitors, saying she did not want to "inconvenience" hospital staff and insisting her stay should be "as low key as possible", sources said.
The Duke of Edinburgh will attend a function at the Royal Thames Yacht Club in London this evening in his capacity as an honorary member of the Imperial Poona Yacht Club, while the Princess Royal is attending the Society of Heads annual conference in Wales.
It is ten years since the Queen was last in hospital, and on that occasion she was admitted for a scheduled operation on her knee.
Gastroenteritis is an infection of the stomach and bowel, often caused by either norovirus or food poisoning, and can be passed on by hand to hand contact.
The Queen has cancelled or postponed all of her engagements for this week, including a visit to Rome as a guest of the outgoing president of Italy.
King Edward VII is the same hospital that treated the Duchess of Cambridge last year when she developed severe pregnancy sickness.
Her Majesty, who carried out 425 official engagements last year, regards her hospital stay as a "minor inconvenience" and expects to be back in action next week, starting with a day of Commonwealth events on Monday and carrying on with a visit to Tech City in east London on Wednesday.