Buckingham Palace said: “It is with deep sorrow that Her Majesty The Queen has announced the death of her beloved husband, His Royal Highness Prince Philip, Duke of Edinburgh.
“His Royal Highness passed away peacefully this morning at Windsor Castle.”
Boris Johnson said he “inspired the lives of countless young people”.
Speaking at Downing Street, the prime minister added: “He helped to steer the Royal Family and the monarchy so that it remains an institution indisputably vital to the balance and happiness of our national life.”
Scotland’s First Minister Nicola Sturgeon said she was “saddened” by the death of the Duke.
She tweeted: “I send my personal and deepest condolences – and those of scotgov and the people of Scotland – to Her Majesty The Queen and her family.”
The prince married Princess Elizabeth in 1947, five years before she became Queen, and was the longest-serving royal consort in British history.
In March, the Duke of Edinburgh left the hospital after a month-long stay for treatment.
He underwent a procedure for a pre-existing heart condition at another London hospital – St Bartholomew’s.
Prince Philip and the Queen had four children, eight grandchildren, and 10 great-grandchildren.
Their first son, the Prince of Wales, Prince Charles, was born in 1948, followed by his sister, Princess Royal, Princess Anne, in 1950, the Duke of York, Prince Andrew, in 1960, and the Earl of Wessex, Prince Edward, in 1964.
Prince Philip was born on the Greek island of Corfu on 10 June 1921.
His father was Prince Andrew of Greece and Denmark, a younger son of King George I of the Hellenes.
His mother, Princess Alice, was a daughter of Lord Louis Mountbatten and a great-granddaughter of Queen Victoria.