Four suspected gunmen behind the deadliest attack in Russia in 20 years are Tajik citizens
Philip, the Duke of Edinburgh, was admitted last week to the King Edward VII Hospital in London which is regularly used by the royal family.
Former naval officer Philip retired from public life last August, quipping at the time that he was no longer able to "stand up much".
"His Royal Highness The Duke of Edinburgh left King Edward VII’s Hospital at midday today, following a hip replacement operation last week. The Duke will continue his recovery at Windsor," Buckingham Palace said in a statement.
"His Royal Highness would like to convey his appreciation for the messages of good wishes he has received," it added.