The Duke, 91, was admitted to ARI on Wednesday, during his and the Queen's annual summer break at Balmoral.
He shook hands with hospital staff and looked in good spirits this morning before being driven away.
Yesterday, he missed a church service attended by the Royal family, as he continued to receive treatment for a flare-up of a bladder infection.
The Queen and the Prince of Wales were among those attending the service at Crathie Kirk, near Balmoral, while the Duke remained in hospital.
He did not receive any visits from his relatives after being advised by doctors on Friday to rest, but is said to have been in regular contact by telephone.
When the Duke was admitted to the NHS hospital officials said he would be in the infirmary for a few days.
His latest health scare comes less than three months after he spent five nights in hospital with a bladder infection following the Diamond Jubilee Pageant on the River Thames.
He had to miss some of the key celebrations for the Queen's 60-year reign after being admitted to the King Edward VII Hospital in London the day after braving wet and windy elements on a barge for several hours. He also had a successful procedure to clear a blocked coronary artery in December and was in hospital for four nights over Christmas.
He and the Queen went to Balmoral after attending several Olympic events.
The couple attended the opening ceremony and toured the Olympic Park.
The Duke also saw his granddaughter Zara Phillips make her Olympic equestrian debut and watched boxing.
He also appeared to be in good spirits recently when he took part in events as part of Cowes Week on the Isle of Wight.
When he was in Scotland earlier this month, he supported the Queen at engagements including hosting a tea party at Balmoral.
It is not yet known whether he will attend his next official engagement – accompanying the Queen to the opening of the London 2012 Paralympic Games on August 29.




